Browser dom speed tests

JavaScript performance comparison

Test case created

Info

Tests to see what speeds the browser DOM runs at in various browsers.

DOM Core Performance: Appending, Prepending, Inserting, Indexing, Removing

InnerHTML

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

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Append
     testAppend(div);
pending…
innerHTML
testInnerHTML(div)
pending…
Prepend
     testPrepend(div);
pending…
Insert
     testInsert(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. Here’s a list of current revisions for this page:

0 comments

Add a comment