Last active
January 24, 2025 14:23
-
-
Save larchanka/602eb5b3921de92369b9b3caffceafc2 to your computer and use it in GitHub Desktop.
JavaScript function to calculate the total size of all data stored in browser's 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
/** | |
* Calculates the total size of all the items in local storage. | |
* @returns {Number} The total size of all the items in local storage in bytes. | |
*/ | |
function calculateLocalStorageSize() { | |
return new Blob(Object.keys(localStorage).map(k => k + localStorage[k])).size; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment