jQuery id vs other

JavaScript performance comparison

Revision 41 of this test case created

Info

This testcase compares the performance from $('#id') and .function()

Preparation code

<div id="container"><form id="formElem" name="formElem" action="" method="post">
                    <fieldset class="step">
                        <img src="1.jpg" >
                    </fieldset>
                    <fieldset class="step">
                        <img id="img2" src="2.jpg" >
                    </fieldset>
                    <fieldset class="step">
                        <img src="3.jpg" >
                    </fieldset>
                </form>
</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
parent
var img = $('#img2'),container=$('#container');
img.parent().parent().children('fieldset');
pending…
id
var img = $('#img2'),container=$('#container');
$('#formElem',container).children('fieldset');
pending…
id
var img = $('#img2'),container=$('#container');
container.find('#formElem').children('fieldset');
pending…
id
var img = $('#img2'),container=$('#container');
$('#formElem').children('fieldset');
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