createDocumentFragment vs appendChild on non-appended element (v15)

Revision 15 of this benchmark created on


Preparation HTML

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

</div>

Test runner

Ready to run.

Testing in
TestOps/sec
Normal Append
var array = ["one","two","three","four","five"], 
i,
testDiv = $("#testDiv1");
    
var ul = $("<ul>");
for (i = 0; i < 5; i +=1)
{
    var li = $("<li>").text(array[i]);
    ul.append(li);
    console.log(ul.length)
}
testDiv.append(ul).hide();
ready
Document Fragment
var frag = document.createDocumentFragment(),
    array = [
        "one","two","three","four","five"
    ], i;
    
var ul = document.createElement('ul');
for (i = 0; i < 5; i +=1)
{
    var li = document.createElement('li');
    li.innerHTML = array[i];
    ul.appendChild(li);
    console.log(ul.length)
}
frag.appendChild(ul);
document.getElementById("testDiv1").appendChild(frag);
ready

Revisions

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