jQuery Child Selector Test

JavaScript performance comparison

Test case created by

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="wrapper">
 <div class="child-1"></div>
 <div class="child-2"></div> 
</div>
      
<script>
Benchmark.prototype.setup = function() {
  var $parent = $('#wrapper');

};
</script>

Preparation code output

<div id="wrapper"> <div class="child-1"></div> <div class="child-2"></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
Find Child of Cached Selector
var $child = $parent.find('.child-1');
pending…
Find child with regular selector
var $child = $('.child-1');
pending…
Find child with children()
var $child = $parent.children('.child-1');
pending…

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

0 Comments