Children vs ">"

JavaScript performance comparison

Revision 2 of this test case created by Ralph Holzmann

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>
window.$142 = jQuery.noConflict(true);
</script>

<script src = "//ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>

<script>
window.$143 = jQuery.noConflict(true);
</script>

<script>
  var $foo142 = $142("#foo");
  var $foo143 = $143("#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 (1.4.2)
$foo142.find("> h2 a");
pending…
Children + Find (1.4.2)
$foo142.children("h2").find("a");
pending…
Direct Descendant Selector + Find (1.4.3)
$foo143.find("> h2 a");
pending…
Children + Find (1.4.3)
$foo143.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