3 ms·
Kill it off? I don't think so. Avoid using it if it's not the right tool for the job? Certainly. As a simple cross-browser key-value storage mechanism it beats
by tagawa 15y ago
Kill it off? I don't think so. Avoid using it if it's not the right tool for the job? Certainly. As a simple cross-browser key-value storage mechanism it beats cookies hands down in my experience, but obviously doesn't compare to database-style alternatives.
- masklinn 15y ago> Kill it off? I don't think so. Avoid using it if it's not the right tool for the job? Certainly. As a simple cross-browser key-value storage mechanism it beats cookies hands down in my experience Exactly. localStorage is not a database, hence not having "database" in its name as opposed to "Indexed Database" or "Web SQL Database". It's a persistent key/value store, aka a big hashmap/dictionary which survives restarts. If you need a database, it's not the right tool for the job, and if you want to store tens of megabytes of shit in the browser it's not the right tool for the job either. If you need to store a bunch of site-wide configuration items or to cache some basic information, it's quite good enough, and at the same time safer, easier to use and providing far more storage space than cookies (which are the actual alternative). The big issue is that we do not have a stable cross-browser client-side database interface (some browsers implement IndexedDB, others implement WebSQL), so people try to jump the gun and coerce localStorage into a DB role... which unsurprisingly breaks.