jquery vs js (add paragraph)

Benchmark created by paabson on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<body>
</body>

Test runner

Ready to run.

Testing in
TestOps/sec
jquery
$('<p/>', {text:''}).appendTo('body');
ready
js
document.body.appendChild(
    document.createDocumentFragment()
    .appendChild( 
        document.createElement('div')
        .appendChild( document.createTextNode(''))
     )
);
ready
js with function
function fillDocumentFragment() {
    var frag = document.createDocumentFragment(),
        argLen = arguments.length;

    for (var i=0; i < argLen; i++) {
        frag.appendChild(arguments[i]);
    }
    return frag;
}


document.body.appendChild(fillDocumentFragment(
    document.createElement('div'),
    document.createTextNode('text')
));
ready

Revisions

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

  • Revision 1: published by paabson on