documentFragment appendChild vs jquery append (v28)

Revision 28 of this benchmark created on


Preparation HTML

<div id="test-area" style="height: 75px; width: auto; overflow:scroll">
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>

Teardown


    $('#test-area').empty();
  

Test runner

Ready to run.

Testing in
TestOps/sec
raw javascript
var raw_fragment = document.createDocumentFragment();
//var i = 1;
//for (i; <= 100000; i++) {
var p = document.createElement("p");
$(p).click(function(){ console.log('clicked from raw js'); });
p.appendChild(document.createTextNode("raw javascript, documentFragment"));
raw_fragment.appendChild(p);
//}
document.getElementById('test-area').appendChild(raw_fragment);
ready
jquery
//var jq_fragment = $(document.createElement('div'));
var jq_fragment = document.createDocumentFragment();

//var i = 1;
//for (i; <= 100000; i++) {
var p = $('<p>jquery elements</p>');
p.click(function(){ console.log('clicked from jquery'); });
jq_fragment.appendChild(p[0]);
//}
document.getElementById('test-area').appendChild(jq_fragment);
//$('#test-area').append(jq_fragment);
ready

Revisions

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