Jquery Selector - Traversing

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="test">
  <ul>
    <li>
      <a class="select1" href="#"></a>
    </li>
    <li>
      <a class="select" href="#"></a>
    </li>
    <li>
      <a class="select" href="#"></a>
    </li>
    <li>
      <a class="select" href="#"></a>
    </li>
    <li>
      <a class="select1" href="#"></a>
    </li>
    <li>
      <a class="select" href="#"></a>
    </li>
    <li>
      <a class="select" href="#"></a>
    </li>
    <li>
      <a class="select" href="#"></a>
    </li>
    <li>
      <a class="select1" href="#"></a>
    </li>
    <li>
      <a class="select" href="#"></a>
    </li>
    <li>
      <a class="select1" href="#"></a>
    </li>
    <li>
      <a class="select" href="#"></a>
    </li>
    <li>
      <a class="select" href="#"></a>
    </li>
    <li>
      <a class="select" href="#"></a>
    </li>
    <li>
      <a class="select1" href="#"></a>
    </li>
    <li>
      <a class="select" href="#"></a>
    </li>
    <li>
      <a class="select1" href="#"></a>
    </li>
  </ul>
</div>

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
Selector 1
$('#test ul li a.select')
pending…
Selector 2
$('#test > ul > li > a.select')
pending…
Selector 3
$('#test .select')
pending…
Selector 4
$('#test a.select')
pending…
Traversing 1
$('#test').find('.select')
pending…
Traversing 2
$('#test').find('a.select')
pending…
Comp Traversing 1
$(".select","#test");
pending…
Multiple1
$(".select","#test");
$(".select1","#test");
pending…
Multiple 2
var a = $("#test");
a.find(".select");
a.find(".select1");
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