jQuery .find() vs descendant selector (v43)

Revision 43 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div>
<div id="container">
<div></div>
<div></div>
<div class="robotarm"></div>
<div><div class="robotarm"></div></div>
<div class="robotarm"></div>
<div class="robotarm"></div>
</div> 
<!--end of container -->
<div></div>
<div class="moreclasses"><div class="moreclasses2"></div></div>
<div class="moreclasses"><div class="moreclasses2"></div></div>
<div class="moreclasses"><div class="moreclasses2"></div><div class="moreclasses2"></div><div class="moreclasses4"></div></div>
<div class="moreclasses2"></div><div class="moreclasses2"><div class="moreclasses2"></div></div>
<div class="moreclasses"><div class="moreclasses3"><div class="moreclasses2"></div></div></div>
<div class="moreclasses"><div class="moreclasses2"><div class="moreclasses2"></div></div></div>
<div class="moreclasses"></div>
<div class="moreclasses"></div>

</div>

Test runner

Ready to run.

Testing in
TestOps/sec
Descendant Selector with tag
$('#container div.robotarm');
ready
Descendant Selector without tag
$('#container .robotarm');
ready
Find with tag
$('#container').find('div.robotarm');
ready
Find without tag
$('#container').find('.robotarm');
ready
Direct search with tag
$('div.robotarm');
ready
Direct search without tag
$('.robotarm');
ready
Double find
$('#container').find('div').find('.robotarm');
ready

Revisions

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