jQuery .find() vs.children selector vs. context selector (v105)

Revision 105 of this benchmark created on


Description

comparing selector speed

Preparation HTML

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

<article>
        <div><p><em><a>A test</a></em></p></div>
        <div><p><ins></ins></p></div>
        <div><p><span><a>This is text</a></span></p></div>
</article>

Setup

var $article = $('article');

Test runner

Ready to run.

Testing in
TestOps/sec
find method1
var has = $article.find('p').find('ins').length > 0 ? true : false;
ready
find method2
var has = $article.find('p ins').length > 0 ? true : false;
ready
find method3
var has = $article.find('p').children('ins').length > 0 ? true : false;
ready
find method4
var has = $article.find('p > ins').length > 0 ? true : false;
ready

Revisions

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