jquery :eq vs :first vs (sel).eq(0)

Benchmark created by jsPop on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<div>
<div data-beard-node="asdf"><div data-beard-node="asdf"></div><div data-beard-node="asdf"></div></div><div data-beard-node="asdf"></div><div data-beard-node="asdf"><div data-beard-node="asdf"><div data-beard-node="asdf"></div></div><div data-beard-node="asdf"><div data-beard-node="asdf"></div><div data-beard-node="asdf"></div></div></div><div data-beard-node="asdf"></div><div data-beard-node="asdf"></div>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
:eq(0)
$('[data-beard-node="asdf"]:eq(0)')
ready
:first
$('[data-beard-node="asdf"]:first')
ready
.eq(0)
$('[data-beard-node="asdf"]').eq(0)
ready
.first()
$('[data-beard-node="asdf"]').first()
ready

Revisions

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