innerHTML vs replaceChild (v2)

Revision 2 of this benchmark created by Amaan on


Preparation HTML

<div id="innerTest">
</div>
<div id="createTest">
  <h2>
    New
  </h2>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
innerHTML
document.getElementById('innerTest').innerHTML = "<h2>New</h2>";
ready
createElement
var h = document.createElement('h2');
var v = document.getElementById('createTest');
h.appendChild(document.createTextNode("New"));
v.replaceChild(h, v.firstChild);
ready

Revisions

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