documentFragment appendChild vs jquery append (v27)

Revision 27 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.10.1/jquery.min.js">
</script>
<script>
_$ = jQuery.noConflict();
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js">
</script>
<script>
_$2 = jQuery.noConflict();
</script>

Teardown


    _$2('#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.appendChild(document.createTextNode("raw javascript, documentFragment"));
raw_fragment.appendChild(p);
//}
document.getElementById('test-area').appendChild(raw_fragment);
ready
jquery 1
var jq_fragment = _$();

//var i = 1;
//for (i; <= 100000; i++) {
var p = _$('<p/>');
p.append("jquery elements");
jq_fragment.add(p);
//}
_$('#test-area').append(jq_fragment);
ready
jquery 2
var jq_fragment = _$2();

//var i = 1;
//for (i; <= 100000; i++) {
var p = _$2('<p/>');
p.append("jquery elements");
jq_fragment.add(p);
//}
_$2('#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.