selector test id/id id/id class

JavaScript performance comparison

Revision 26 of this test case created by Joseph Presley

Info

Rev 26 Notes: Added Test 9 to compare getElementByID without jQuery vs with jQuery wrapper.

Preparation code

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


<div id="Mytbl">
<div id="MyElement"></div>
<div class="MyClass"></div>
</div>

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
Direct ID
$('#MyElement');
pending…
Nested ID's
$('#Mytbl #MyElement')
pending…
ID - Class
$('#Mytbl .MyClass')
pending…
find()
$("#Mytbl").find(".MyClass");
pending…
Context
$("div.MyClass", "#Mytbl");
pending…
ID / Class with Tag
$('#Mytbl div.MyClass')
pending…
Direct ID getElementByID w/ jQuery
$(document.getElementById("Mytbl"));
pending…
getElementByID as context
$("div.MyClass", document.getElementById("Mytbl"));
pending…
getElementByID without Jquery
document.getElementById("Mytbl");
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