Skip to content

Instantly share code, notes, and snippets.

@diegocasmo
Last active August 29, 2015 14:25
Show Gist options
  • Save diegocasmo/5df854f8d34e8acf24d6 to your computer and use it in GitHub Desktop.
Save diegocasmo/5df854f8d34e8acf24d6 to your computer and use it in GitHub Desktop.
Calculates localStorage key and total size occupied by data in MB
var total = 0;
for (var key in localStorage) {
var keySize = ((localStorage[key].length * 2) / 1024 / 1024).toFixed(2);
console.log(key + '=' + keySize + ' MB');
total += parseFloat(keySize);
}
console.log('total=' + total.toFixed(2) + ' MB');
@cabe56
Copy link

cabe56 commented Jul 24, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment