Test jQuery append performance

JavaScript performance comparison

Test case created by EragonJ

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div class="grid-container">
  <div class="grid">
  </div>
</div>
<script>
Benchmark.prototype.setup = function() {
    var $gridTpl = $(".grid"),
        $gridContainer = $(".grid-container");
};

Benchmark.prototype.teardown = function() {
    $(".grid-container").remove();
};
</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 one by one
var i, len;
var $grid = $gridTpl.clone();

for(i = 0, len = 1000; i < len; i = i + 1) {
  $gridContainer.append($grid);
}
pending…
append once
var i, len, grids = [];
var $grid = $gridTpl.clone();

for(i = 0, len = 1000; i < len; i = i + 1) {
  grids.push($grid.get(0));
}

$gridContainer.append( grids );
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

1 comment

EragonJ (revision owner) commented :

check http://api.jquery.com/append/

we can use $().append( [] ) .

Add a comment