jQuery Attribute selector performance (v12)

Revision 12 of this benchmark created on


Description

Test to see if jQuery filters by selector before doing attribute matching.

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div class="x" id="container">
<b class="t" name="test0" id="id_test0"><span class="u" id="span0">a</span></b>
<b class="t" name="test0" id="id_test1"><span class="u" id="span1">a</span></b>
<b class="t" name="test0" id="id_test2"><span class="u" id="span2">a</span></b>
<b class="t" name="test1" id="id_test3"><span class="u" id="span3">a</span></b>
<b class="t" name="test1" id="id_test4"><span class="u" id="span4">a</span></b>
<b class="t" name="test1" id="id_test5"><span class="u" id="span5">a</span></b>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
tag+attr id
$('b[id="id_test3"]');
ready
byid
$("#id_test3");
ready
name
$('b#id_test3');
ready
$('#id_test3 #span3');
ready
$('#span3');
ready
$('#id_test3 u');
ready
$('#container').find('[name$=test1]')
ready
$('#container').find('[name=test1]')
ready

Revisions

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