Skip to content

Instantly share code, notes, and snippets.

@nandomoreirame
Created April 5, 2021 16:41
Show Gist options
  • Save nandomoreirame/668794a04f647d89c7636769c254380c to your computer and use it in GitHub Desktop.
Save nandomoreirame/668794a04f647d89c7636769c254380c to your computer and use it in GitHub Desktop.
how much is in localstorage
let _lsTotal = 0;
let _xLen;
let _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