jQuery Cache / No-Cache

JavaScript performance comparison

Revision 13 of this test case created by Benny Bennet

Preparation code

<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<div id="test">HELLO</div>
      
<script>
Benchmark.prototype.setup = function() {
  var domEl = document.getElementById('test');
  var $domEl = $(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
Cache
$domEl.width('100px');
$domEl.width('200px');
$domEl.width('300px');
$domEl.width('400px');
$domEl.width('500px');
$domEl.width('600px');
pending…
No-Cache ReSelect
$("#test").width('100px');
$("#test").width('200px');
$("#test").width('300px');
$("#test").width('400px');
$("#test").width('500px');
$("#test").width('600px');
pending…
No-Cache
$(domEl).width('100px');
$(domEl).width('200px');
$(domEl).width('300px');
$(domEl).width('400px');
$(domEl).width('500px');
$(domEl).width('600px');
pending…
Cache + css()
$domEl.css('width', '100px');
$domEl.css('width', '200px');
$domEl.css('width', '300px');
$domEl.css('width', '400px');
$domEl.css('width', '500px');
$domEl.css('width', '600px');
pending…
noJquery
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…
noJquery 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…
noJquery, using with
with(domEl) {
  style.width = '100px';
  style.width = '200px';
  style.width = '300px';
  style.width = '400px';
  style.width = '500px';
  style.width = '600px';
}
pending…
noJquery, no Cache
document.getElementById('test').style.width = '100px';
document.getElementById('test').style.width = '200px';
document.getElementById('test').style.width = '300px';
document.getElementById('test').style.width = '400px';
document.getElementById('test').style.width = '500px';
document.getElementById('test').style.width = '600px';

/*
 * Be aware that this style causes layout trashing:
 * http://wilsonpage.co.uk/preventing-layout-thrashing/
 */
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