createDocumentFragment vs appendChild on non-appended element (v11)

Revision 11 of this benchmark created by Lonnen on


Setup

var form = document.createElement('form'),
        array = [],
        iterations = 400,
        i;
    
    for (i = 0; i < iterations; i += 1)
    {
        array.push(document.createElement('input'))
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Normal Append
for (i = 0; i < iterations; i +=1)
{
    form.appendChild(array[i]);
}

document.body.appendChild(form);
document.body.offsetHeight;
document.body.removeChild(form);
ready
Document Fragment
var formDiv = document.createDocumentFragment();

for (i = 0; i < iterations; i +=1)
{
    formDiv.appendChild(array[i]);
}
    
form.appendChild(formDiv);
document.body.appendChild(form);
document.body.offsetHeight;
document.body.removeChild(form);
ready

Revisions

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