.each versus .find.each

JavaScript performance comparison

Test case created by Alex Judd

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div class="test">
<a name="a1"></a>
<a name="a2"></a>
<a name="a3"></a>
<a name="a4"></a>
<a name="a5"></a>
<a name="a6"></a>
<a name="a7"></a>
<a name="a8"></a>
<a name="a9"></a>
<a name="a10"></a>
</div>

    

Preparation code output

<div class="test"> <a name="a1"></a> <a name="a2"></a> <a name="a3"></a> <a name="a4"></a> <a name="a5"></a> <a name="a6"></a> <a name="a7"></a> <a name="a8"></a> <a name="a9"></a> <a name="a10"></a> </div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
.each
$(".test a")
pending…
.find.each
$(".test").find("a")
pending…
scope
$("a", ".test")
pending…
querySelectorAll
document.querySelectorAll(".test a")
pending…

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

1 Comment

Alex Judd (revision owner) commented :

Strangely it would appear that .find is faster than a direct selector