innerHTML vs replaceChild (v6)

Revision 6 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 = "<h2>a" + Math.random() + "b</h2>";
ready
createElement
var h = document.createTextNode("<h2>a" + Math.random() + "b</h2>");
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 = "<h2>a" + Math.random() + "b</h2>";
ready

Revisions

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