Append Array of jQuery Elements

Benchmark created by Peter on


Preparation HTML

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

Setup

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

Teardown


    $elts = null;
    $('#test').empty();
  

Test runner

Ready to run.

Testing in
TestOps/sec
Append in each
$.each($elts, function(i, $elt) {
    $test.append($elt);
});
 
ready
Convert to list of DOM elements and append
var elts = $.map($elts, function($elt) {
    return $elt.get();
});
$test.append(elts);
ready
Append list of jQuery elements
$test.append($elts);
ready

Revisions

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