scroped selector vs find jquery

JavaScript performance comparison

Test case created by TheSisb

Preparation code

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


<div id='ee'>
  <div class='aa'></div>
  <div class='bb'></div>
  <div class='cc'></div>
  <div class='dd'></div>
  <div class='ff'></div>
</div>
 
<script>
Benchmark.prototype.setup = function() {
    var $el = $('#ee');
};
</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
scoped select
$('.ff', $el).each(function() {
  return true;
});
pending…
find jquery
$el.find('.ff').each(function() {
  return true;
});
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

Add a comment