Last active
March 28, 2017 16:19
-
-
Save whitehat101/dcfcbac20b91dc822ddcdd7fdfe86c16 to your computer and use it in GitHub Desktop.
Measure HTML5 localStorage (in MB)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(chars, index) { | |
for (chars = index = 0; index < localStorage.length; index++ ) | |
chars += localStorage.getItem(localStorage.key(index)).length | |
return `${(chars/1024/1024).toPrecision(5)} MB ≈${(chars/5/1024/1024*100).toPrecision(3)}%` | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test storage limits: https://arty.name/localstorage.html