Descending

JavaScript performance comparison

Test case created by Josh

Info

Determining the fastest way to descend down to child elements.

Preparation code

<div id="parent">
    <div>
        <p>Paragraph.</p>
    </div>
    <div>
        <h2>Heading</h2>
        <p>Paragraph.</p>
    </div>
</div>

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

Preparation code output

Paragraph.

Heading

Paragraph.

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
$('#parent h2').text();
pending…
Children
$('#parent').children('div').children('h2').text();
pending…
Find
$('#parent').find('h2').text();
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

Add a comment