awful selector

JavaScript performance comparison

Test case created by Rick Waldron

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>var j142 = jQuery.noConflict();</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>var j15 = jQuery.noConflict();</script>

<!-- #menu>ul>li>ul>li>a -->
<div id="menu">
  <ul>
    <li>
      <ul>
        <li><a href="#a">alpha</a></li>
        <li><a href="#b">beta</a></li>
        <li><a href="#g">gamma</a></li>
        <li><a href="#d">delta</a></li>
      </ul>
    </li>
  </ul>
</div>
    

Preparation code output

<!-- #menu>ul>li>ul>li>a --> <div id="menu"> <ul> <li> <ul> <li><a href="#a">alpha</a></li> <li><a href="#b">beta</a></li> <li><a href="#g">gamma</a></li> <li><a href="#d">delta</a></li> </ul> </li> </ul> </div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
j142: #menu>ul>li>ul>li>a
j142("#menu>ul>li>ul>li>a").parent();
pending…
j142: #menu ul li ul li a
j142("ul li ul li a", j142("#menu")).parent();
pending…
j15: #menu>ul>li>ul>li>a
j15("#menu>ul>li>ul>li>a").parent();
pending…
j15: #menu ul li ul li a
j15("ul li ul li a", j15("#menu")).parent();
pending…

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

Compare results of other browsers

0 Comments