Children vs ">"

JavaScript performance comparison

Test case created by Doug Neiner

Info

A test to see how the alternative syntax would function to the find('> ...') direct descendent selector.

Preparation code

<div id="foo">
  <h2>Article <small><a href="#">Link</a></small></h2>
  <div class="content">
    <p>Hello</p>
  </div>
</div>
<script src = "//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
  var $foo = $("#foo");
</script>

Preparation code output

Article Link

Hello

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Direct Descendant Selector + Find
$foo.find("> h2 a");
pending…
Children + Find
$foo.children("h2").find("a");
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