jQuery find versus context versions 1.4.2 to 1.5

JavaScript performance comparison

Test case created by jcfant

Preparation code

<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.min.js"></script>
<script>
var $15 = jQuery.noConflict();
</script>

<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.4.min.js"></script>
<script>
var $144 = jQuery.noConflict();
</script>

<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
<script>
var $142 = jQuery.noConflict();
</script>


<div class="wrapper">
     <div class="innerWrapper">
          <div class="button">
               <a href="javascript:void(0)" id="button" class="buttonRef">
                    <span class="buttonText">Text</span>
               </a>
          </div>
     </div>
</div>
<script>
  var context5 = $15("div.wrapper");
  var context44 = $144("div.wrapper");
  var context42 = $142("div.wrapper");
</script>
    

Preparation code output

<script> var $15 = jQuery.noConflict(); </script> <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.4.min.js"></script> <script> var $144 = jQuery.noConflict(); </script> <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js"></script> <script> var $142 = jQuery.noConflict(); </script> <div class="wrapper"> <div class="innerWrapper"> <div class="button"> <a href="javascript:void(0)" id="button" class="buttonRef"> <span class="buttonText">Text</span> </a> </div> </div> </div> <script> var context5 = $15("div.wrapper"); var context44 = $144("div.wrapper"); var context42 = $142("div.wrapper"); </script>

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
Get - document
var item = document.getElementById("button");
pending…
Get - ID 1.4.2
var item = $142("#button");
pending…
Get - ID 1.4.4
var item = $144("#button");
pending…
Get - ID 1.5
var item = $15("#button");
pending…
Context - ID 1.4.2
var item = $142("#button", context42);
pending…
Context - ID 1.4.4
var item = $144("#button", context44);
pending…
Context - ID 1.5
var item = $15("#button", context5);
pending…
Find - ID 1.4.2
var item = context42.find("#button")
pending…
Find - ID 1.4.4
var item = context44.find("#button")
pending…
Find - ID 1.5
var item = context5.find("#button")
pending…
Get - Class 1.4.2
var item = $142(".buttonRef");
pending…
Get - Class 1.4.4
var item = $144(".buttonRef");
pending…
Get - Class 1.5
var item = $15(".buttonRef");
pending…
Context - Class 1.4.2
var item = $142(".buttonRef", context42);
pending…
Context - Class 1.4.4
var item = $144(".buttonRef", context44);
pending…
Context - Class 1.5
var item = $15(".buttonRef", context5);
pending…
Find - Class 1.4.2
var item = context42.find(".buttonRef")
pending…
Find - Class 1.4.4
var item = context44.find(".buttonRef")
pending…
Find - Class 1.5
var item = context5.find(".buttonRef")
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