innerHTML vs removeChild

JavaScript performance comparison

Revision 397 of this test case created by

Preparation code

<div id='box'></div>
      
<script>
Benchmark.prototype.setup = function() {
  var box = document.getElementById('box');
  var child = '<b>child</b>';
  var child_string = '';

};
</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
removeChild
for (var i = 0; i < 100; i++) {
 child_string += '<b>tags</b>'
};

box.innerHTML = child_string;
pending…
innerHTML
for (var i = 0; i < 100; i++) {
  box.innerHTML = child;
};
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