jQuery append, string vs. $collection vs. elements (v145)

Revision 145 of this benchmark created by jz on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>

<div id="list"></div>

Setup

var len = 20;
    var html = '';
    for (var i = 0; i < len; i++) {
      html += '<div>Test ' + i + '</div>';
    }
    
    var $divs = $(html);
    
    var divs = $divs.get();
    
    var $list = $('#list');

Test runner

Ready to run.

Testing in
TestOps/sec
jquery .append() string
$list.append(html);
ready
jquery append $element
$list.append($divs);
ready
jquery append element
$list.append(divs);
ready

Revisions

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