Created
May 28, 2025 13:42
-
-
Save steffensbola/4319238a1357a513c8e00c8f0700fd86 to your computer and use it in GitHub Desktop.
Get the size of each entry in the Browser Local Storage
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
| /* Gets the size of each entry in the Browser Local Storage. Original: https://stackoverflow.com/questions/4391575/how-to-find-the-size-of-localstorage*/ | |
| var _lsTotal=0,_xLen,_x;for(_x in localStorage){ if(!localStorage.hasOwnProperty(_x)){continue;} _xLen= ((localStorage[_x].length + _x.length)* 2);_lsTotal+=_xLen; console.log(_x.substr(0,50)+" = "+ (_xLen/1024).toFixed(2)+" KB")};console.log("Total = " + (_lsTotal / 1024).toFixed(2) + " KB"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment