Browser Diet - DOM Manipulation

JavaScript performance comparison

Revision 3 of this test case created and last updated

Preparation code

<div id="myList"></div>

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
DOM manipulation every iteration
var myList = document.getElementById("myList");

for (var i = 0; i < 100; i++) {
  myList.innerHTML += "<div>" + i + "</div>";
}
pending…
DOM manipulation after all iterations
var myList = "";

for (var i = 0; i < 100; i++) {
  myList += "<div>" + i + "</div>";
}

document.getElementById("myList").innerHTML = myList;
pending…
Join array of strings
var myList = [];

myList.push("<div>0")
for (var i = 1; i < 99; i++) {
  myList.push(i.toString());
}
myList.push("99</div>");

document.getElementById("myList").innerHTML = myList.join("</div><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