insertAdjacentHTML-vs-innerHTML (v7)

Revision 7 of this benchmark created on


Preparation HTML

<div id="counter">
</div>

Teardown


    document.getElementById("counter").innerHTML = "";
  

Test runner

Ready to run.

Testing in
TestOps/sec
insertAdjacentHTML
document.getElementById("counter").insertAdjacentHTML('beforeend', '<span>hello</span>');
ready
innerHTML
document.getElementById("counter").innerHTML = '<span>hello</span>';
ready
hack
el = document.getElementById("counter");
/*@cc_on // Pure innerHTML is slightly faster in IE
        el.innerHTML = '<span>hello</span>';
        return;
    @*/
var newEl = el.cloneNode(false);
newEl.innerHTML = '<span>hello</span>';
el.parentNode.replaceChild(newEl, el);
ready

Revisions

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