Skip to content

Instantly share code, notes, and snippets.

@gaelbillon
Created September 25, 2012 11:58
Show Gist options
  • Save gaelbillon/3781339 to your computer and use it in GitHub Desktop.
Save gaelbillon/3781339 to your computer and use it in GitHub Desktop.
get localstorage size bookmarklet
<a href="javascript:localStorageSize=null;for(var a=0;a<localStorage.length;a++)localStorageSize+=localStorage.getItem(localStorage.key(a)).length;var b=localStorageSize,c=['Bytes','KB','MB','GB','TB'];if(0==b)localStorageSize='n/a';else{var d=parseInt(Math.floor(Math.log(b)/Math.log(1024)),10);localStorageSize=0==d?b+' '+c[d]:(b/Math.pow(1024,d)).toFixed(1)+' '+c[d]}alert('localStorage is : '+localStorageSize);">localStorage Size</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment