innerHTML vs replaceChild (v7)

Revision 7 of this benchmark created on


Preparation HTML

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

Test runner

Ready to run.

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

Revisions

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