innerHTML vs replaceChild (v3)

Revision 3 of this benchmark created on


Preparation HTML

<div id="testdiv"><h2>New</h2></div>

Test runner

Ready to run.

Testing in
TestOps/sec
innerHTML
document.getElementById('testdiv').innerHTML = "<h2>a" + Math.random() + "b</h2>";
ready
createElement
var h = document.createElement('h2');
var v = document.getElementById('testdiv');
h.appendChild(document.createTextNode("a" + Math.random() + "b"));
v.replaceChild(h, v.firstChild);
ready
textContent
document.getElementById('testdiv').firstChild.textContent = "a" + Math.random() + "b";
ready
data
document.getElementById('testdiv').firstChild.firstChild.data = "a" + Math.random() + "b";
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.