getElementById VS jQuery('#id') (v105)

Revision 105 of this benchmark created by Oleksandr Kelepko on


Preparation HTML

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

<script>
for(var i = 0; i < 1000; ++i){
  $('<p id="foo' + i + '">Test</p>').appendTo($(document.body));
}
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
getElementById
document.getElementById('foo555');
ready
jQuery
$('#foo555');
ready
jQuery with getElementById
$(document.getElementById('foo555'));
ready
getElementById - missing
document.getElementById('fooBar')
ready
jQuery - missing
$('#fooBar')
ready

Revisions

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