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

Revision 112 of this benchmark created by matt on


Description

Compare context.find(id) with (id)

Preparation HTML

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

<div id="someId">
<p>A test</p>
<p>
     <p id="#somePId" class="someClass"></p>
</p>
<p>This is text</p>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
Find id
var hasFrame = $('#somePId').length > 0 ? true : false;
ready
Find id from context
var $context = $('#someId')
var hasFrame = $context.find('#somePId').length > 0 ? true : false;
ready

Revisions

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