09 December 2009


Lately I've been doing a bit of work with the new "localStorage" browser variable that's part of the HTML5 spec.  It allows you to store key/value pairs by just setting them as a property of the "localStorage" window variable, up to a total size of 10MB (I think).

The variable is accessed on a per-domain basis, and is maintained after browser shutdown.  (A similiar variable called "sessionStorage" does the exact same thing but is erased at every browser shutdown or window close.)

Pretty amazing to anyone who's spent years storage little bits of data in 4KB cookies over the years, I tell you what.  Now, usually I stay away from developments such as these, mostly because Microsoft's Internet Explorer never supports them, and 90% of my development is spent in IE.

However, imagine when my surprise when I found out that Microsoft, for whatever reason, actually decided to adopt the HTML5 localStorage spec in IE8.

Surprised the hell out of me.   Once I learned that Safari 4, Chrome 4, and Firefox 3.5 also support the HTML5 localStorage spec, I decided to adopt it in my coding.

Ah, but what about IE6?  Or FF2?  For that, I turned to a little library I found called PersistJS that, while it hadn't been updated for 2 years,  looked like it would do the trick.  It supposedly supports a myriad of various browser storage techniques, stepping down from each to a lesser version depending upon what it finds supported in its environment.

Still trying to get it to work, however -- like I said, the library is several years old, and while I did find its github repository, it's still mostly in development and doesn't seem to work quite well yet.  If it wasn't for IE6 (and Firefox 2 and Firefox 3.0.x, to a lesser degree), I'd probably just scrap the idea of using an external library, and just go on to using the native localStorage spec.

(...this might be a perfect opportunity to drop support for IE6, don't you think?)

No comments:

Post a Comment