pure localstorage vs cookie vs jstorage.js

Benchmark created by nik on


Preparation HTML

<script src="https://raw.github.com/EchoAppsTeam/js-sdk/master/src/cookie.js"></script>
<script src="https://raw.github.com/andris9/jStorage/master/jstorage.js"></script>
<script src="https://raw.github.com/pamelafox/lscache/master/lscache.js"></script>

Setup

var obj = {
      "number": 123,
      "line": "some string",
      "array": [1,{},[],"str"],
      "obj": {
        "test": "foo"
      }
    };

Test runner

Ready to run.

Testing in
TestOps/sec
localstorage
localStorage['foo'] = JSON.stringify(obj);
JSON.parse(localStorage['foo']);
delete localStorage['foo'];
ready
cookie
Echo.Cookie.set('foo', JSON.stringify(obj));
JSON.parse(Echo.Cookie.get('foo'));
Echo.Cookie.remove('foo');
ready
jstorage.js
$.jStorage.set('foo', obj);
$.jStorage.get('foo');
$.jStorage.deleteKey('foo');
 
ready
lscache.js
lscache.set('bar', obj);
lscache.get('bar');
lscache.remove('bar');
ready
sessionStorage
sessionStorage.setItem('foo', JSON.stringify(obj));
JSON.parse(sessionStorage.getItem('foo'));
sessionStorage.removeItem('foo');
ready

Revisions

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