Skip to content

Instantly share code, notes, and snippets.

@diegocasmo
Last active August 29, 2015 14:25
Show Gist options
  • Select an option

  • Save diegocasmo/5df854f8d34e8acf24d6 to your computer and use it in GitHub Desktop.

Select an option

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 x in localStorage) {
console.log(x + '=' + ((localStorage[x].length * 2) / 1024 / 1024).toFixed(2) + ' MB');
total += parseFloat(((localStorage[x].length * 2) / 1024 / 1024).toFixed(2));
}
console.log('total=' + total + ' 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