.first() vs :first vs eq(0) (v14)

Revision 14 of this benchmark created on


Description

which is faster .first(), :first or .eq(0)?

Stack Overflow Question: http://stackoverflow.com/questions/2312761/jquery-first-vs-first

Preparation HTML

<ul>
  <li>One</li>
  <li>Two</li>
  <li>Three</li>
  <li>Four</li>
  <li>Five</li>
</ul>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
.first()
console.log(
  $('ul li').first().text()
);
ready
:first
console.log(
  $('ul li:first').text()
);
ready
.eq(0)
console.log(
  $('ul li').text()
);
ready

Revisions

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