jquery.cookie

JavaScript performance comparison

Revision 2 of this test case created by

Preparation code

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.3.1/jquery.cookie.min.js"></script>
      
<script>
Benchmark.prototype.setup = function() {
  $.cookie("TEST", 123);
  $.cookie("TEST2", 345);
  $.cookie("TEST3", 123);
  $.cookie("TEST4", 345);
  $.cookie("TEST5", 123);
  $.cookie("TEST6", 345);
  
  var getCookieValue = function(key) { 
    return $.cookie(key);
  }
  
  var cookieHash = {};
  var getHashedCookieVal = function(key) {
    if (cookieHash[key] == null) {
      cookieHash[key] = $.cookie(key);
    }
    return cookieHash[key];
  }

};

Benchmark.prototype.teardown = function() {
  $.cookie("TEST", null);
  $.cookie("TEST2", null);
  $.cookie("TEST3", null);
  $.cookie("TEST4", null);
  $.cookie("TEST5", null);
  $.cookie("TEST6", null);
  

};
</script>

Preparation code output

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.3.1/jquery.cookie.min.js"></script>

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
Accessing Cookie via $.cookie
var value = getCookieValue("TEST")
pending…
Accessing Cookie via object hash
// async test
var value = getHashedCookieVal("TEST")
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