innerHTML vs removeChild

JavaScript performance comparison

Revision 416 of this test case created by Jay Carlson

Preparation code

<div id='box'></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='box'></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
is lastChild cached
write();
while (box.firstChild) {
  box.removeChild(box.lastChild);
}
pending…

Revisions

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

0 Comments