JQuery :first vs .first()

Benchmark created by Scott Baker on


Preparation HTML

<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

Revisions

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