jQuery("#id")

JavaScript performance comparison

Revision 3 of this test case created by Timmy Willison

Info

The duplicate id optimization in jQuery.fn.init has been removed. Check the loss.

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
var $1_7_2 = jQuery.noConflict();
</script>
<script src="https://dl.dropbox.com/u/6407061/jQuery/sizzle_optimize/jquery.js"></script>
<script>
var $git = jQuery.noConflict();
</script>
<div id="test" class="test">
<div id="child"></div>
</div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<script>
Benchmark.prototype.setup = function() {
    var $1_7_2test = $1_7_2("#test");
    var $gittest = $git("#test");
    $1_7_2test.on("blink", "div.test", $1_7_2.noop);
    $gittest.on("blink", "div.test", $git.noop);
};
</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
1.7.2 trigger
$1_7_2test.trigger("blink");
pending…
git trigger
$gittest.trigger("blink");
pending…
1.7.2 simple match
$1_7_2test.is("div.test");
pending…
git simple match
$gittest.is("div.test");
pending…
1.7.2 pseudo match
$1_7_2test.is("div:first-child");
pending…
git pseudo match
$gittest.is("div:first-child");
pending…
1.7.2 complex pseudo match
$1_7_2test.is("div:first-child:has(#child)");
pending…
git complex pseudo match
$gittest.is("div:first-child:has(#child)");
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