4 ms·
I was using (abusing?) localStorage for a game I'm working on. I was using it to store entries for every word in the English dictionary, which is around 85,00
by unoti 15y ago
I was using (abusing?) localStorage for a game I'm working on. I was using it to store entries for every word in the English dictionary, which is around 85,000 entries. I needed two entries per word actually, because I needed it indexed two ways. It worked; I tested it on Chrome Linux, Mac Safari, a first generation ipad, and on Android. However, it was slow to load, and started erroring out sometimes in Chrome Linux, saying quota exceeded or something along those lines. Basically I ended up deciding that localStorage wasn't right for me for large amounts of data, and redid it another way.
These look like awesome and useful abstractions for a lot of things, I may use it for saving and loading games, for example. But I recommend caution if you're thinking about using localStorage to store a lot of entries.
- pamelafox 15y agoThe quota for localStorage varies from 2MB to well, very high, depending on the browser. The average is around 5MB. There's a page here that shows results for various browsers: http://dev-test.nemikor.com/web-storage/support-test/ http://dev-test.nemikor.com/web-storage/support-test/ It's not advisable to use it for a lot of data, especially if you actually need that data to stay around - it's better in situations where it's okay if the data goes away. You also need to be ready to handle over quota errors - e.g. in my lscache library, we kick out old data when that happens. I talked about that in a localStorage talk recently (http://client-side-storage.appspot.com/ http://client-side-storage.appspot.com/ - click "show notes"). You might want to use the Lawnchair library, as that can be used with both localStorage and IndexedDB, which can theoretically handle a lot more data with better performance.
- unoti 15y agoThanks for sharing this! lscache is super cool. I also just watched and thoroughly enjoyed your Google IO talk on shyness work-arounds (http://www.youtube.com/watch?v=52Ml_zax4A0&t=24m9s http://www.youtube.com/watch?v=52Ml_zax4A0&t=24m9s). Great stuff all around.