jQuery(getElementById) vs jQuery

Benchmark created by Martin Bieder (@binarious) on


Description

Check if jQuery(document.getElementById('myId')) is faster than jQuery('#myId')

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<input type="button" id="huhu" value="Btn">
<input type="button" id="huhu2" value="Btn">
<input type="button" id="huhu3" value="Btn">
<input type="button" id="huhu4" value="Btn">
<input type="button" id="huhu5" value="Btn">
<input type="button" id="huhu6" value="Btn">

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery
jQuery('#huhu').length
ready
getElementById
jQuery(document.getElementById('huhu')).length
ready

Revisions

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

  • Revision 1: published by Martin Bieder (@binarious) on