basket.js
basket.js copied to clipboard
Usage in Private Browsing mode
While debugging a site in iOS I saw that my home-baked localStorage caching script was failing in private mode:
QuotaExceededError: DOM exception 22: An attempt was made to add something to storage that exceeded the quota
I see that you check for this error here: https://github.com/addyosmani/basket.js/blob/gh-pages/lib/basket.js#L15 — could you explain for the layman what's happening here and how basket.js handles caching of resources during private browsing (if at all)?
The referenced code sorts all localStarage items managed by basket.js and removes the oldest entry (recursively, until no error is thrown).
Private mode in Safari hower, throws the QuotaExceededError
when accessing localStorage, so it can't store anything. MDN gives an example how to handle this.