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

Revision 22 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>

Test runner

Ready to run.

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

Revisions

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