jQuery vs createElement (v203)

Revision 203 of this benchmark created on


Description

Benchmarks from answer on StackOverflow: http://stackoverflow.com/questions/268490/jquery-document-createelement-equivalent/268520

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
$('<div>')
$('<div class="one" eletype="input"><input type="radio" value="1"/>')
ready
$('<div></div>')
$('<div class="one" eletype="input"><input type="radio" value="1"/></div>')
ready
document.createElement
var d = document.createElement('div');
var i = document.createElement('input');
i.setAttribute('type', 'radio');
i.setAttribute('value', '1');
d.setAttribute('class', 'one');
d.setAttribute('eletype', 'input');
d.appendChild(i);
$(d)
ready
Test 4
var d, i;

d = $(document.createElement('div')).addClass('one').attr('eletype', 'input');

i = $(document.createElement('input')).attr('type', 'radio').val('1');

d.append(i);
 
ready

Revisions

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