JQuery :last vs .last() (v6)

Revision 6 of this benchmark created on


Description

Which one is the fast

Preparation HTML

<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>

Test runner

Ready to run.

Testing in
TestOps/sec
:last
$('body link[type="text/javascript"]:last').replaceWith($replaceElement);
ready
.last( ) #1
$('body link[type="text/javascript"]').last().replaceWith($replaceElement);
ready
.last( ) #2
$objSelector.last().replaceWith($replaceElement);
ready
.filter(:last)
$objSelector.filter(":last").replaceWith($replaceElement);
ready

Revisions

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