top | item 1468802

Store.js - cross browser local storage without using cookies or flash

155 points| narcvs | 15 years ago |github.com | reply

62 comments

order
[+] Myrth|15 years ago|reply
It would be nice to know limitations (by browser/version?)

I.e. maximum storage size, scope (global, 2nd level domain, any domain), life cycle (when is it cleared), etc.

[+] barredo|15 years ago|reply
From the readme:

"So far tested in

Tested in Firefox 2.0 Tested in Firefox 3.0 Tested in Firefox 3.6 Tested in Chrome 5 Tested in Safari 4 Tested in Safari 5 Tested in IE6 Tested in IE7 Tested in IE8 Tested in Opera 10"

Does it mean it works on IE6+? Does IE6 have local storage?

[+] narcvs|15 years ago|reply
IE6 has userData behavior, which can be used to store data on the client just like with local storage
[+] alc277|15 years ago|reply
I've seen some frameworks that use flash storage as a last resort for IE6. I've found success just building in a ajax fail-over and then let IE6 or any other browser make use of the fail-over.
[+] kingsley_20|15 years ago|reply
Probably uses Adobe Flash storage in browsers that don't support a db.
[+] n8agrin|15 years ago|reply
It seems as though the author does not believe in semicolon use in Javascript. Looks interesting though.
[+] marcuswestin|15 years ago|reply
I use semicolons when they're needed (for loops, multiple statements per line), and don't use them when they're not. The code becomes cleaner to my eyes.
[+] chip|15 years ago|reply
Do you plan to add length? ie localstorage.length, etc. I'll like to implement this on http://readmelater.com

Looks great by the way!

[+] empire29|15 years ago|reply
Anyone know of size limitations on this storage? I am in the middle of writing a jQuery plugin and storing data in cookies which have the 4KB size limitation (which resulted in me having to "chunk" the data across several cookies). This looks like the perfect alternative!
[+] Groxx|15 years ago|reply
I think Safari defaults to 10MB, though I may have changed it and forgotten doing so.
[+] eli|15 years ago|reply
Be careful, there's a limit on how many total cookies you can have per domain too.
[+] philfreo|15 years ago|reply
also be aware that data is getting submitted to your domain on every request -- not great for performance
[+] tobyhede|15 years ago|reply
For a different take on local storage, have a look at MilkCrate http://github.com/garrow/milkcratejs

MilkCrate is a wrapper around html localStorage/globalStorage that provides support for saving and querying collections of objects. MilkCrate attempts to implement a similar querying interface to mongoDB.

[+] Dylan16807|15 years ago|reply
It works now that I stuck it on a server, but apparently FF3.6.4 drops the data between passes on a file:// url. IE6 and Opera10 hang on to it, nothing else available here.
[+] paraschopra|15 years ago|reply
I just tested. Like cookies, it also obeys domain-only visibility. So, all hopes for cross-domain user tracking are still doomed. sigh
[+] dandelany|15 years ago|reply
I'm completely unconvinced that cross-domain local storage is even remotely a good idea. I can't think of any data I'd want to store in a clientside database that I would want other sites to be able to see/modify.

  So, all hopes for cross-domain user tracking are still doomed. sigh
Um, this is a good thing. I don't want the sites I visit to be communicating my use patterns to each other.
[+] orangecat|15 years ago|reply
So, all hopes for cross-domain user tracking are still doomed. sigh

I would certainly hope so...

[+] cheald|15 years ago|reply
Why on earth would you imply that cross-domain user tracking is a good thing?
[+] Groxx|15 years ago|reply
(to repliers)

</sarcasm>

[+] wolfhumble|15 years ago|reply
Tested it on IE 6 and got: "Tests passed" So I guess it works . . . :-)
[+] narcvs|15 years ago|reply
Yup, it works in IE6.

I don't have access to IE5.5, would love to have someone test it.

[+] eli|15 years ago|reply
In theory localStorage should work on iPhone and Android 2.0+ too
[+] erlanger|15 years ago|reply

  Fix issue 1, rename store.del() to store.remove()
  marcuswestin (author)
  18 minutes ago
Will the API be stabilized? Or can you alias method names in cases like this, rather than clobbering them?
[+] alunny|15 years ago|reply
It's a sixty line JS file that's been online for less than a day. I don't think API stability is a major concern at this point.
[+] marcuswestin|15 years ago|reply
erlanger: you can consider the API stable now.