jquery find speed vs selector

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

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

<div id="myDiv">
  <img src="#" />
</div>

<script>
for(var i = 0; i<5000; i++){
$('img').appendTo('#myDiv');
}
</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
find
$("#myDiv").find("img").addClass('test');
pending…
selector
$('#myDiv img').addClass('test');
pending…
selector 2
$('img',$('#myDiv')).addClass('test');
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. Here’s a list of current revisions for this page:

0 comments

Add a comment