jQuery Chaining Only

JavaScript performance comparison

Test case created by Josh Gruber

Info

sub-sample test of furf's http://jsperf.com/jquery-chaining-vs-caching/ to allow analysis of memory

Preparation code

<script src="http://code.jquery.com/jquery.min.js"></script>
<b style="display:block;" id="byID" class="byClass"></b>
<script>
Benchmark.prototype.setup = function() {
    $('#byID').css({
      'border': 'none',
      'background': 'transparent',
      'width': 'auto',
      'height': 'auto'
    }).text('');
   
};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
chaining, ID selector
$('#byID')
  .css('border', '4px dashed red')
  .css('background', 'purple')
  .width('400px')
  .height('300px')
  .text('you are my sunshine, my only sunshine.');
pending…
chaining, class selector
$('.byClass')
  .css('border', '4px dashed red')
  .css('background', 'purple')
  .width('400px')
  .height('300px')
  .text('you are my sunshine, my only sunshine.');
pending…
chaining, nodeName selector
$('b')
  .css('border', '4px dashed red')
  .css('background', 'purple')
  .width('400px')
  .height('300px')
  .text('you are my sunshine, my only sunshine.');
pending…

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

Compare results of other browsers

0 comments

Add a comment