descend-from-id-vs-select-and-find

JavaScript performance comparison

Test case created

Preparation code

<div id="#myId">
  <span>
    Some content
  </span>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>

Preparation code output

Some content

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Descend from #id
$('#myId span')
pending…
Select then find
$('#myId').find('span')
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:

1 comment

Puah Hock Leng commented :

Tested with jQuery 2.0, although the sizzle engine in jqeury core has been improved, there is still performance difference between using pure selector and using find().

Add a comment