Any idea how to check the remaining storage space in an HTML5 localstorage data store?
Click the Application tab to open the Application panel. Expand the Local Storage menu. Click a domain to view its key-value pairs. Click a row of the table to view the value in the viewer below the table.
It is limited to about 5MB and can contain only strings. LocalStorage is not accessible from web workers or service workers. Cookies have their uses, but should not be used for storage.
localStorage browser support To be sure the browser supports localStorage , you can check using the following snippet: if (typeof(Storage) !== "undefined") { // Code for localStorage } else { // No web storage Support. }
I don't know if this helps, but you can check if it full.
“QUOTA_EXCEEDED_ERR” is the exception that will get thrown if you exceed your storage quota of 5 megabytes.
And this other answer might be related.
Default localStorage allocated size is: 5Mb
var allocated = 5;
var total = 0;
for(var x in localStorage){
var amount = (localStorage[x].length * 2) / 1024 / 1024;
total += amount;
}
var remaining = allocated - total;
console.log( "Used: " + total + " MB");
console.log( "Remaining: " + remaining + " MB");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With