$('#foo') vs. $x.find('#foo')

JavaScript performance comparison

Test case created by

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="wrap1">
<div id="wrap2">
<div id="content">
foo
</div>
</div>
</div>
      
<script>
Benchmark.prototype.setup = function() {
  $x = $('#wrap2');

};
</script>

Preparation code output

<div id="wrap1"> <div id="wrap2"> <div id="content"> foo </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
$()
var $y = $('#content');
pending…
.find()
var $y = $x.find('#content');
pending…

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

Compare results of other browsers

0 Comments

foo