cached id vs jquery id

JavaScript performance comparison

Revision 7 of this test case created by

Preparation code

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

<div id="0">
<div id="01">
<div id="02">
<div id="03">
<div id="04">
</div>
</div>
</div>
</div>
</div>

<div id="1">
<div id="11">
<div id="12">
<div id="13">
<div id="14">
</div>
</div>
</div>
</div>
</div>

<div id="2">
<div id="21">
<div id="22">
<div id="23">
<div id="24">
</div>
</div>
</div>
</div>
</div>

<div id="3">
<div id="31">
<div id="32">
<div id="33">
<div id="34">
</div>
</div>
</div>
</div>
</div>
      
<script>
Benchmark.prototype.setup = function() {
  var c = $("#3");

};
</script>

Preparation code output

<div id="0"> <div id="01"> <div id="02"> <div id="03"> <div id="04"> </div> </div> </div> </div> </div> <div id="1"> <div id="11"> <div id="12"> <div id="13"> <div id="14"> </div> </div> </div> </div> </div> <div id="2"> <div id="21"> <div id="22"> <div id="23"> <div id="24"> </div> </div> </div> </div> </div> <div id="3"> <div id="31"> <div id="32"> <div id="33"> <div id="34"> </div> </div> </div> </div> </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
jquery extra
var x = $("div#34");
pending…

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments