jQuery Caching 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
caching, ID selector
var el = $('#byID');

el.css('border', '4px dashed red');
el.css('background', 'purple');
el.width('400px');
el.height('300px');
el.text('you are my sunshine, my only sunshine.');
pending…
caching, class selector
var el = $('.byClass');

el.css('border', '4px dashed red');
el.css('background', 'purple');
el.width('400px');
el.height('300px');
el.text('you are my sunshine, my only sunshine.');
pending…
caching, nodeName selector
var el = $('b');

el.css('border', '4px dashed red');
el.css('background', 'purple');
el.width('400px');
el.height('300px');
el.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