Append Array of jQuery Elements

JavaScript performance comparison

Revision 5 of this test case created by thdk

Preparation code

<div id="test"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

      
<script>
Benchmark.prototype.setup = function() {
  var $elts = [];
  for (var i=0; i<100; i++) {
      $elts.push($('<span>', {text: i}));
  }
  var $test = $('#test');

};

Benchmark.prototype.teardown = function() {
  $elts = null;
  $('#test').empty();

};
</script>

Preparation code output

<div id="test"></div>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
append in each
$.each($elts, function(i, $elt) {
    $test.append($elt);
});
pending…

Revisions

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

0 Comments