innerHTML vs replaceChild (v5)

Revision 5 of this benchmark created by Amaan 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

Revisions

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