append list of jQuery Elements to dom

JavaScript performance comparison

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 items
$test.append($elts);
pending…
detach container before appending
$test.detach();
$test.append($elts);
$("#container").append($test);
pending…

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

0 Comments