massive append

JavaScript performance comparison

Test case created by dfcreative

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 
<script>
Benchmark.prototype.setup = function() {
    var items = "";
    for (var i = 0; i < 1000; i++){
    items += '<div class="item" id="' + i + '"></div>'
    }
   
    var div = document.createElement("div");
    div.innerHTML = items;
   
};
</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
Fragment
var df = document.createDocumentFragment(),
ch = div.children;
for (var i = 0; i < ch; i++){
df.append(ch[i]);
}
$(document.body).append(df);
pending…
jQuery append
var $items = $(div.children);
$(document.body).append($items)
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment