jQuery Simple Selector

JavaScript performance comparison

Test case created by John Resig and last updated

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>var jq142 = jQuery.noConflict();</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script>var jq144 = jQuery.noConflict();</script>
<script src="//code.jquery.com/jquery-git.js?asdf"></script>
<script>var jq15 = jQuery.noConflict();</script>
<div class="test" id="test">
<script>
var html = "";
for ( var i = 0; i < 500; i++ ) {
  html += '<div class="find"></div>';
}
document.write( html );
</script>
</div>
<script>
  var $jq142 = jq142("body");
  var $jq144 = jq144("body");
  var $jq15 = jq15("body");
</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
Class 1.4.2
$jq142.find(".find");
pending…
Class 1.4.4
$jq144.find(".find");
pending…
Class 1.5
$jq15.find(".find");
pending…
Tag 1.4.2
$jq142.find("div");
pending…
Tag 1.4.4
$jq144.find("div");
pending…
Tag 1.5
$jq15.find("div");
pending…
Document ID 1.4.2
jq142("#test")
pending…
Document ID 1.4.4
jq144("#test")
pending…
Document ID 1.5
jq15("#test")
pending…
Body 1.4.2
jq142("body")
pending…
Body 1.4.4
jq144("body")
pending…
Body 1.5
jq15("body")
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