remove children (v266)

Revision 266 of this benchmark created by DanMan on


Description

what method for empty a element is faster ?

Preparation HTML

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

Setup

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

Teardown


    write();
  

Test runner

Ready to run.

Testing in
TestOps/sec
remove firstChild
while (box.firstChild) {
  box.removeChild(box.firstChild);
}
ready
set empty innerHTML
box.innerHTML = '';
ready
set empty innerText
box.innerText = '';
ready
Test 1, avoiding repaint
box.style.display='none';
box.innerHTML = '';
box.style.display='';

 
ready
cloneNode
var dupNode = box.cloneNode(false);
box.parentNode.replaceChild(dupNode, box);
 
ready

Revisions

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