Basic DOM manipulation

JavaScript performance comparison

Revision 4 of this test case created by Gabriel R. Giannattasio

Preparation code

<div id="container"></div>
      
<script>
Benchmark.prototype.setup = function() {
     var div = document.createElement('div'),
         p = document.createElement('p'),
         el = document.getElementById('container');

};

Benchmark.prototype.teardown = function() {
  el.innerHTML = '';

};
</script>

Preparation code output

<div id="container"></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
Only one DOM write
div.appendChild(p);
el.appendChild(div);
pending…
Two DOM writes
el.appendChild(div);
div.appendChild(p);
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