jQuery Cached Set (v48)

Revision 48 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<div id="top" class="mydiv">
  <p id="para_1" class="mytext">
    Paragraph one
  </p>
  <p id="para_2" class="mytext">
    Paragraph two
  </p>
  <p id="para_3" class="mytext r1" data-idf='1'>
    Paragraph three
  </p>
  <span id="span_1" class="mytext r1" data-idf='2'>
    Text in a span
  </span>
</div>
<p id="para_4" class="mytext">
  Paragraph four
</p>
<p id="para_5" class="r1">
  Paragraph five
</p>
<p id="para_6" class="mytext" data-idf='2'>
  Paragraph six
</p>
<script>
  var parent_el = document.getElementById("top");
  var cached = jQuery(parent_el).find('p.mytext');
  var $t=$('#top'), $p=$t.find('p');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Cached elements
$t.find('*').filter( function() { return !$(this).hasClass('r1'); } );
ready
No cache
$t.children().filter( function() { return !$(this).hasClass('r1'); } );
ready
Cache2
$t.find('p').not('.r1');
ready
Cach3
$t.find('p').filter( function() { if($(this).hasClass('r1')) return false; else return true;  } );
ready
parseInt
$t.find('p').filter( function() { return !$(this).hasClass('r1'); } );
ready

Revisions

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