Is jQuery traversal preferred over selectors

JavaScript performance comparison

Test case created

Info

Is jQuery traversal preferred over selectors? http://stackoverflow.com/questions/15216838/is-jquery-traversal-preferred-over-selectors

Preparation code

<div id="vacations">
  <p>
    hello
  </p>
  <ul>
    <li>
      A
    </li>
    <li>
      B
    </li>
    <li>
      C
    </li>
  </ul>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>

Preparation code output

hello

  • A
  • B
  • C

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Traversal
jQuery(document).ready(function($) {
  $("#vacations").find("li").last();
});
pending…
Selectors
jQuery(document).ready(function($) {
  $("#vacations li:last");
});
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