Browser dom speed tests

JavaScript performance comparison

Test case created by

Preparation code

<div></div> 
<script>
     var count = 100;
     var divs = new Array(count);
     var div = document.getElementsByTagName('div')[0]
  
     function testAppend(div) {
         var add = document.createElement('div');
         for (var i = 0; i<=1000;i++) {
             div.appendChild(add);
         }
     }
   
     function testPrepend(div) {
         var add = document.createElement('div');
         for (var i = 0; i<=1000;i++) {
             div.insertBefore(add, div.firstChild);
         }
     }
   
     function testInnerHTML(div) {
         for (var i = 0; i<=1000;i++) {
             div.innerHTML = "<div></div>";
         }
     }
     function testInnerHTMLBuffer(div) {
         var buffer=[];
         for (var i = 0; i<=1000;i++) {
             buffer.push("<div></div>")
         }
         div.innerHTML = buffer.join("");
     }
   
     function testInsert(div) {
         var add = document.createElement('div');
         for (var i = 0; i<=1000;i++) {
             div.insertBefore(add, div[0]);
         }
     }
  
</script>
    

Preparation code output

<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
Append
     testAppend(div);
pending…
Prepend
     testPrepend(div);
pending…
Insert
     testInsert(div);
pending…
innerHTML
testInnerHTML(div)
pending…
innerHTML + buffer
testInnerHTMLBuffer(div)
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