The Reports of WebSQL’s Death Have Been Greatly Exaggerated

Every time I poke around the interwebs looking for docs on various forms of offline storage, I find folks saying that WebSQL is ‘dead’, or more often: ‘deprecated’. Not so. It’s just that every browser that implemented WebSQL used SQLite, so work on a formal standard stopped:

The specification reached an impasse: all interested implementors have used the same SQL backend (Sqlite), but we need multiple independent implementations to proceed along a standardisation path.

There’s a huge difference between stopping work on a standard, and recommending that browsers drop a feature. <blink> was deprecated. SQLite is an effective, documented and well-maintained de facto standard, which made further work on a formal standard pretty pointless, and a clear violation of W3C’s goal of having at least 3 different implementations of something.

So, “dead” is definitely not the right way to express it. ‘Suspended animation’ more like. Trapped in carbonite.

3 years since work stopped on the standard, it’s still active in half the internet clients in the world, and nobody has dropped it. The question is whether IE and Firefox will ever get over themselves and implement something that clearly works pretty well, and if Chrome, Safari & Opera will see any need to drop it before that can happen. Note that Firefox already ships with SQLite included for internal use, but limits its availability to “trusted callers, meaning extensions and Firefox components only.”

I’ve had great success with WebSQL in Cordova apps, where the notional security risks basically disappear because the usage and exposure profile is so different. It’s supported on all major Cordova platforms except Windows 8. It allows devs to re-use their existing knowledge of SQL to easily perform some pretty handy feats, like comparing the online and offline versions of a file index. For the web, I’m going to take it for granted that the security isn’t perfect. But *nothing* that runs in the browser is inherently secure. Use it accordingly. That’s the reality of web engineering. Fixating on SQL’s shortcomings at the expense of its strengths seems pretty short-sighted to me, especially when Mozilla would just have to expose something that’s already present in their product.

I’ll probably continue to use WebSQL in mobile HTML apps. That said, this may be a better way to go on the web in the medium term, as it lets you use IndexedDB in all A-grade browsers that support either WebSQL or IndexedDB. So, one solution would address all major clients. That just means learning IndexedDB. <blech> I really wish I could find any commenters who like IndexedDB…

Another option I’m looking at is Breeze.js. You get LINQ-style queries, but just store the data in key-value localStorage or sessionStorage as JSON. That should work pretty much everywhere. (IE8!?!)

Tagged , , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: