jQuery .find() vs. context selector vs non-context selector (v97)

Revision 97 of this benchmark created by TechGeek01 on


Description

comparing selector speed

Preparation HTML

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

<article>
        <p>A test</p>
        <p><ins></ins></p>
        <p><blockquote>This is text</blockquote></p>
</article>

Test runner

Ready to run.

Testing in
TestOps/sec
Standard selector
var has = $('article ins, article blockquote').length > 0 ? true : false;
ready
Context
var has = $('ins, blockquote', $('article')).length > 0 ? true : false;
ready
.find()
var has = $('article').find('ins, blockquote').length > 0 ? true : false;
ready
Cached main element with .find()
var $article = $('article'), has = $article.find('ins, blockquote').length > 0 ? true : false;
ready

Revisions

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