remove children

JavaScript performance comparison

Revision 137 of this test case created by DanMan

Preparation code

<div id='wrap'>
<div id='box'></div>
</div>
      
<script>
Benchmark.prototype.setup = function() {
  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);
  
  }

};
</script>

Preparation code output

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

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
remove firstChild
write();
while (box.firstChild) {
  box.removeChild(box.firstChild);
}
pending…
set empty innerHTML
write();
box.innerHTML = '';
pending…
set empty innerText
write();
box.innerText = '';
pending…
Test 1, avoiding repaint
write();
box.style.display='none';
box.innerHTML = '';
box.style.display='';

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

Compare results of other browsers

Revisions

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

0 Comments