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

Revision 156 of this benchmark created by Derek on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
</script>
<p id="foo">
  Test
</p>
<p class="bar">
  bars
</p>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery + getElementById
jQuery(document.getElementById('foo'));
ready
jQuery for ID
jQuery('#foo');
ready
getElementById for ID
document.getElementById('foo');
ready
jQuery for class
jQuery('.bar');
ready
getElementsByClassName for class
document.getElementsByClassName('bar');
ready
querySelectorAll for class
document.querySelectorAll('.bar');
ready
querySelectorAll for ID
document.querySelectorAll('#foo');
ready

Revisions

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