JQuery :last vs .last()

JavaScript performance comparison

Test case created by geovanno

Info

Which one is the fast

Preparation code

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
  var $pathJquery = 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js';
 
  var $objSelector = $('body link[type="text/javascript"]');
 
  var $replaceElement = '<link type="text/javascript" rel="stylesheet" href="' + $pathJquery + '" />\n';
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
:last
$('body link[type="text/javascript"]:last').replaceWith($replaceElement);
pending…
.last( ) #1
$('body link[type="text/javascript"]').last().replaceWith($replaceElement);
pending…
.last( ) #2
$objSelector.last().replaceWith($replaceElement);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment