Comparing jQuery's .filter VS .not VS :not (v5)

Revision 5 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<tbody id='tbody'>
<p>
  Single P
</p>
<p class="first-class">
  <p class="2-class">
     <p class="3-class">
        <p class="4-class">
           P with class
       </p>
     </p>
  </p>
</p>
<p id="first-id">
  P with it
</p>
<p class="second-class" id="second-id">
  P with class and ID
</p>
</tbody>

Test runner

Ready to run.

Testing in
TestOps/sec
Using .filter
var $tbody = $('tbody');
$tbody.find('[id*=4-class]').closest('tbody');
ready
Using .not
var $tbody = $('tbody');
$tbody.find('[id*=4-class]').parents('tbody');
ready
Using find
var $tbody = $('tbody');
$tbody.find('[id*=4-class]');
ready

Revisions

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