getElementById VS jQuery('#id') VS jQuery('#id', 'body') (v47)

Revision 47 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="#container'>
<p id="foo">
  Test
</p>
</div>

Setup

window.container = $('#container')[0];

Test runner

Ready to run.

Testing in
TestOps/sec
getElementById
document.getElementById('foo');
ready
jQuery
$('#foo');
ready
jQuery (w/ context query)
$('#foo', '#container');
ready
jQuery (w/ context)
$('#foo', window.divContainer);
ready
jQuery (w/ selector)
$('div#container #foo');
ready
jQuery (w/ find)
$('#container').find('#foo');
ready
byId then jQ
$(document.getElementById('foo'));
ready

Revisions

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