☞ Need help? I have an open spot for consulting in my schedule. Hire me.

Check Storage Used

This code sample will allow you to check how much of your allowed storage quota you are using via localStorage (maximum depends on browser).

function checkStorageUsed() {
    var dim = thisDim = 0;
    for (var x in localStorage) {
        if (x.indexOf("com.apple.") == -1) {
            thisDim = (localStorage[x].length * 2) / 1024;
            console.log(x + ' :: ' + thisDim + 'kb');
            dim += thisDim;
        }
    }
    alert(dim.toFixed(2) + 'kb');
    return dim.toFixed(2);
}

Directions:
– Call checkStorageUsed(); and you will get a popup showing the result.

Note:
This snippet focuses on iOS development. Make sure to verify/adapt any vendor prefixes.

Back to main listing.