jQuery .find() vs. context selector (v146)

Revision 146 of this benchmark created on


Preparation HTML

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

<article>
<p>A test</p>
<div class="divContainer"><p><iframe></iframe></p></div>
<p>This is text</p>
</article>

Setup

var article = document.querySelector('article');

Test runner

Ready to run.

Testing in
TestOps/sec
context method
var hasFrame = $(article, '.divContainer iframe').length > 0 ? true : false;
ready
find method
var hasFrame = $('.divContainer').find('iframe').find(article).length > 0 ? true : false;
ready

Revisions

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