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

Revision 79 of this benchmark created on


Preparation HTML

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

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

<p><ins></ins></p>

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

<p><ins></ins></p>

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

Setup

var $article = $('article');
  var article = $article[0];

Test runner

Ready to run.

Testing in
TestOps/sec
Find method
var has = $('article').find('p').length > 0 ? true : false;
ready
Contect method
var has = $('article p').length > 0 ? true : false;
ready

Revisions

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