createDocumentFragment vs appendChild on non-appended element (v2)

Revision 2 of this benchmark created by gildas on


Test runner

Ready to run.

Testing in
TestOps/sec
Normal Append
var form = document.createElement('form'),
    array = [
        document.createElement('input'),
        document.createElement('input'),
        document.createElement('input'),
        document.createElement('input')
    ], i;
    
for (i = 0; i < 4; i +=1)
{
    form.appendChild(array[i]);
}
    
document.body.appendChild(form);
document.body.offsetHeight;
document.body.removeChild(form);
ready
Document Fragment
var formDiv = document.createDocumentFragment(),
    form = document.createElement('form'),
    array = [
        document.createElement('input'),
        document.createElement('input'),
        document.createElement('input'),
        document.createElement('input')
    ], i;
    
for (i = 0; i < 4; 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.