jQuery Cache / No-Cache

JavaScript performance comparison

Revision 8 of this test case created by Benny Bennet

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<div id="test">HELLO</div>
      
<script>
Benchmark.prototype.setup = function() {
  var domEl = document.getElementById('test');
  var domElStyle = domEl.style;
  var $el = $(domEl);

};
</script>

Preparation code output

<div id="test">HELLO</div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
plain JS Cached EL-Style
domElStyle.width = '100px';
domElStyle.width = '200px';
domElStyle.width = '300px';
domElStyle.width = '400px';
domElStyle.width = '500px';
domElStyle.width = '600px';
pending…
plain JS setAttribute
domEl.setAttribute('style', 'width: 100px');
domEl.setAttribute('style', 'width: 200px');
domEl.setAttribute('style', 'width: 300px');
domEl.setAttribute('style', 'width: 400px');
domEl.setAttribute('style', 'width: 500px');
domEl.setAttribute('style', 'width: 600px');
pending…
plain JS EL-Style
domEl.style.width = '100px';
domEl.style.width = '200px';
domEl.style.width = '300px';
domEl.style.width = '400px';
domEl.style.width = '500px';
domEl.style.width = '600px';
pending…
jQuery .css (cached EL)
$el.css('width', '100px');
$el.css('width', '200px');
$el.css('width', '300px');
$el.css('width', '400px');
$el.css('width', '500px');
$el.css('width', '600px');
pending…
jQuery Cache
$el.width('100px');
$el.width('200px');
$el.width('300px');
$el.width('400px');
$el.width('500px');
$el.width('600px');
pending…
jQuery No-Cache
$(domEl).width('100px');
$(domEl).width('200px');
$(domEl).width('300px');
$(domEl).width('400px');
$(domEl).width('500px');
$(domEl).width('600px');
pending…

Compare results of other browsers

Revisions

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

0 Comments

HELLO