jQuery id vs other

JavaScript performance comparison

Revision 41 of this test case created by

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="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    

Preparation code output

<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>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
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.

0 Comments