jQuery Find vs Selector

JavaScript performance comparison

Revision 3 of this test case created

Info

Test the speed between: $('#bob a') and $('#bob').find('a') $('#bob .class') and $('#bob').find('.class')

Preparation code

<div>
<nav>
<div id="bob">
<span>Another Node</span>
<span>Another Node</span>
<span>Another Node</span>
<span>Another Node</span>
<span>Another Node</span>
<span>Another Node</span>
<span>Another Node</span>
<span>Another Node</span>
<a href="#" class="class">Bob's your uncle!</a>
<span>Another Node</span>
<span>Another Node</span>
<span>Another Node</span>
<span>Another Node</span>
<span>Another Node</span>
<span>Another Node</span>
<span>Another Node</span>
<span>Another Node</span>
</div>
<nav>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Selector Search
jQuery(document).ready(function($){
$('#bob a').css({'text-decoration':'none'});
});
pending…
Find Search
jQuery(document).ready(function($){
$('#bob').find('a').css({'text-decoration':'none'});
});
pending…
Class Selector Search
jQuery(document).ready(function($){
$('#bob .class').css({'text-decoration':'none'});
});
pending…
Find Class Search
jQuery(document).ready(function($){
$('#bob').find('.class').css({'text-decoration':'none'});
});
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment