innerHTML vs removeChild

JavaScript performance comparison

Revision 34 of this test case created by

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="box"><p>sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g</p></div>
<script>
  var box = document.getElementById("box")
  var backup = box.cloneNode(true)
</script>
      
<script>
Benchmark.prototype.setup = function() {
  var $box = $(box)

};

Benchmark.prototype.teardown = function() {
  box = backup.cloneNode(true)

};
</script>

Preparation code output

<div id="box"><p>sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g<b>s f</b>s df</p><p>df gsdfg sf g</p></div> <script> var box = document.getElementById("box") var backup = box.cloneNode(true) </script>

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
while (box.hasChildren) {
  box.removeChild(box.firstChild)
}
pending…
empty
$box.empty()
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

sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf gs fs df

df gsdfg sf g