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

Benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="div1">
<div id="div2">
<div id="div3">
<div id="div4">
<div id="div5">
<div id="div6">
<div id="div7">
<p id="foo">
  Test
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery
$('#foo');
ready
jQuery on getElementById
$(document.getElementById('foo'))
ready

Revisions

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