innerHTML vs removeChild (v144)

Revision 144 of this benchmark created by empty on


Description

what method for empty a element is faster ?

Preparation HTML

<div id='box'></div>

Setup

window.write = function ()
    {
     var box = document.getElementById('box');
    var div = document.createElement('div');
    div.innerHTML = "halo <br> des <div>aaaa</div><table></table>";
    box.appendChild(div);
    
    }

Test runner

Ready to run.

Testing in
TestOps/sec
removeChild
write();
while (box.firstChild) {
  box.removeChild(box.firstChild);
}
ready
innerHTML
write();
box.innerHTML = '';
ready
innerText
write();
box.innerText = '';
ready
withoutDom
write();
box.style.display='none';
box.innerHTML = '';
box.style.display='';

 
ready

Revisions

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