jQuery ID selector performance (v5)

Revision 5 of this benchmark created by xc on


Preparation HTML

<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<div>
<span id="my-id">My Span</span>
</div>
<form id="form">
<input id="input1" type="text" name="username" value="MyName" />
<textarea id="input2" name="Detail">OhYes</textarea>
</form>

Test runner

Ready to run.

Testing in
TestOps/sec
Normal ID selector
$('div > span#my-id');
ready
Find ID selector
$('div').find('span#my-id');
ready
Form Selector
$('form > input#input1').val();
ready
Form Find Selector
$('form').find('#input1').val();
ready

Revisions

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