domvsstring

JavaScript performance comparison

Revision 4 of this test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script><table id="container">

</table>
<script>
  var d = document.getElementById("container");
  var i;
  var s = "";
  var o;
  var f = function() {};
</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
dom
o = document.createElement("tbody");
d.appendChild(o);
for (i = 0; i < 1000; i++) {
 var tr = document.createElement("tr")
 tr.className = i;
 tr.onclick = f;
 o.appendChild(tr);
}
pending…
string
s = "<tbody>";
for (i = 0; i < 1000; i++) {
 s += "<tr className='" + i + "' onclick=''></tr>";
}
s += "</tbody>";
o.innerHTML = s;
pending…
jquery
o = $("<tbody></tbody>");
$(d).append(o);
for (i = 0; i < 1000; i++) {
 var tr = $("<tr></tr>")
 tr.addClass(i);
 tr.click(f);
 o.append(tr);
}
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