jQuery Cached Set (v4)

Revision 4 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/mootools/1.3/mootools-yui-compressed.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">
    Paragraph three
  </p>
  <span id="span_1" class="mytext">
    Text in a span
  </span>
</div>
<p id="para_4" class="mytext">
  Paragraph four
</p>
<p id="para_5" class="mytext">
  Paragraph five
</p>
<p id="para_6" class="mytext">
  Paragraph six
</p>
<script>
  var parent_el = document.getElementById("top");
  var cached = $$(parent_el).pick().getElements('p.mytext');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Cached elements
cached.setStyle('color', '#ff0000');
cached.setStyle('text-decoration', 'underline');
cached.setStyle('background-color', '#eeeeee');
ready
No cache
$('top').getElements('p.mytext').setStyle('color', '#ff0000');
$('top').getElements('p.mytext').setStyle('text-decoration', 'underline');
$('top').getElements('p.mytext').setStyle('background-color', '#eeeeee');
ready
Cache2
cached.setStyle('color', '#ff0000').setStyle('text-decoration', 'underline').setStyle('background-color', '#eeeeee');
ready
Cach3
cached.setStyles({
  "color": "#ff0000",
  "text-decoration": "underline",
  "background-color": "#eeeeee"
});
ready

Revisions

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