jQuery Big Selector Test2

JavaScript performance comparison

Revision 2 of this test case created

Info

$('.a') vs $('div.a')

Preparation code

<div class="a">
  <div class="b">
    <span class="c">
      <span class="d">
        <span class="e">
          <span class="f">
            <span class="g">
              <a href="" class="h">
              <h1 class="i">
              <h2 class="j">
              <h3 class="k"><i class="l"><b class="m"><abbr title="" class="n"><em class="o"><span class="p"><strong class="r"><span class="s">
              <h5 class="t"><span class="u"><a href="" class="w"><b class="x"><span class="y"><span class="z"><span class="a"><span class="b"><span class="c"><span class="d"><span class="e"><span class="f"><span class="g"><a href="" class="h">
              <h1 class="i">
              <h2 class="j">
              <h3 class="k"><i class="l"><b class="m"><abbr title="" class="n"><em class="o"><span class="p"><strong class="r"><span class="s">
              <h5 class="t"><span class="u"><a href="" class="w"><b class="x"><span class="y"><span class="z"><span class="a"><span class="b"><span class="c"><span class="d"><span class="e"><span class="f"><span class="g"><a href="" class="h">
              <h1 class="i">
              <h2 class="j">
              <h3 class="k"><i class="l"><b class="m"><abbr title="" class="n"><em class="o"><span class="p"><strong class="r"><span class="s">
              <h5 class="t"><span class="u"><a href="" class="w"><b class="x"><span class="y"><span class="z"><span class="a"><span class="b"><span class="c"><span class="d"><span class="e"><span class="f"><span class="g"><a href="" class="h">
              <h1 class="i">
              <h2 class="j">
              <h3 class="k"><i class="l"><b class="m"><abbr title="" class="n"><em class="o"><span class="p"><strong class="r"><span class="s">
              <h5 class="t"><span class="u"><a href="" class="w"><b class="x"><span class="y"><span class="z"><span class="a"><span class="b"><span class="c"><span class="d"><span class="e"><span class="f"><span class="g"><a href="" class="h">
              <h1 class="i">
              <h2 class="j">
              <h3 class="k"><i class="l"><b class="m"><abbr title="" class="n"><em class="o"><span class="p"><strong class="r"><span class="s">
              <h5 class="t"><span class="u"><a href="" class="w"><b class="x"><span class="y"><span class="z"><span class="a"><span class="b"><span class="c"><span class="d"><span class="e"><span class="f"><span class="g"><a href="" class="h">
              <h1 class="i">
              <h2 class="j">
              <h3 class="k"><i class="l"><b class="m"><abbr title="" class="n"><em class="o"><span class="p"><strong class="r"><span class="s">
              <h5 class="t"><span class="u"><a href="" class="w"><b class="x"><span class="y"><span class="z"></span></span></b></a>
            </span>
            </h5>
          </span>
          </strong>
        </span>
        </em>
        </abbr>
        </b>
        </i>
        </h3>
        </h2>
        </h1>
        </a>
      </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </b>
    </a>
    </span>
    </h5>
    </span>
    </strong>
    </span>
    </em>
    </abbr>
    </b>
    </i>
    </h3>
    </h2>
    </h1>
    </a>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </b>
    </a>
    </span>
    </h5>
    </span>
    </strong>
    </span>
    </em>
    </abbr>
    </b>
    </i>
    </h3>
    </h2>
    </h1>
    </a>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </b>
    </a>
    </span>
    </h5>
    </span>
    </strong>
    </span>
    </em>
    </abbr>
    </b>
    </i>
    </h3>
    </h2>
    </h1>
    </a>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </b>
    </a>
    </span>
    </h5>
    </span>
    </strong>
    </span>
    </em>
    </abbr>
    </b>
    </i>
    </h3>
    </h2>
    </h1>
    </a>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </span>
    </b>
    </a>
    </span>
    </h5>
    </span>
    </strong>
    </span>
    </em>
    </abbr>
    </b>
    </i>
    </h3>
    </h2>
    </h1>
    </a>
    </span>
    </span>
    </span>
    </span>
    </span>
  </div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</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
$('.a')
$('.a')
pending…
$('div.a')
$('div.a')
pending…
$('.b').addClass('test')
$('.b').addClass('test')
pending…
$('div.b').addClass('test')
$('div.b').addClass('test')
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