JQuery :first vs .first() vs. eq (v12)

Revision 12 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/prototype/1/prototype.js"></script>
<script src="//www.cinsoft.net/mylib099-min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/ext-core/3/ext-core.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<div>AAAA</div>
<div>BBBB</div>
<div>CCCC</div>
<div>DDDD</div>
<div>EEEE</div>

<div><span>aaaa</span></div>
<div><span>bbbb</span></div>
<div><span>cccc</span></div>
<div><span>dddd</span></div>
<div><span>eeee</span></div>

Test runner

Ready to run.

Testing in
TestOps/sec
.first
$("div").first();
ready
:first
$("div:first");
ready
[0]
$($("div")[0]);
ready

Revisions

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