DOM append methods test

JavaScript performance comparison

Revision 2 of this test case created by Konstantin Savelyev

Preparation code

<script src="//code.jquery.com/jquery-1.3.1.min.js"></script></script>
<ul id="list" style="display:none;">
</ul>
<script>
Benchmark.prototype.setup = function() {
    var arr = [];
   
    for (var i = 0; i < 99; i++) {
      arr[i] = document.createElement('li');
    }
};
</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
whole array at once
$("#list").append(arr);
pending…
document fragment
var fragment = document.createDocumentFragment();

for (var i = 0; i < arr.length; i++) {
  fragment.appendChild(arr[i]);
}

$('#list').append(fragment);
pending…
dummy method with a lot of insert-operations
var list = $("#list");

for (var i = 0; i < arr.length; i++) {
  list.append(arr[i]);
}
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