Pages

Monday, January 21, 2013

IndexedDB via WebSql

IndexedDB Polyfill is "a polyfill to enable IndexedDB using WebSql." Why is something like this needed, you say? Well, the issue comes from the current lack of support for HTML5 storage standards.
As the proposal for WebSQL implementation has been deprecated, the candidate for client-side storage has become IndexedDB standard. This is a key/value object store, not a relational one. However, there are indexes and stores, so it is quite capable as a storage mechanism.
While major desktop browsers support IndexedDB in their current iterations, mobile browsers are not up-to-date with support. The major issue is Android's stock browser which, if you are creating mobile apps, is the execution sandbox for the app. This means that using IndexedDB in an app that executes in the Android browser will not get you anywhere. By default, that is.
Fortunately, there is a project that bridges that gap. IndexedDB PolyFill (axemclion/IndexedDBShim · GitHub) offers IndexedDB APIs via supported storage mechanism, which is WebSQL. In their own words,
IndexedBD is not supported on all browsers. This IndexedDB polyfill exposes the IndexedDB API in unsupported browsers using WebSQL. This shim is basically an IndexedDB-WebSql adapter.

Using this polyfill, you can use a single offline storage API across browsers (Opera, Safari, Firefox, Chrome and IE10) and even mobile devices (Phonegap on iOS and Android).
This is currently a lifesaver, making the code longer-lasting as you can write code that uses IndexedDB APIs and have it work seamlessly through the HTML5 implementation across various browsers.

More:
To see which major browsers support HTML5 features, see this page.

2 comments:

Unknown said...

I'm just beginning to use this lib. Do you know anything as to the performance of the lib? Adding a layer of abjstraction to websql has to slow down to some degree...

Alen's Australia said...

Hi, Patrick,

I find the overall performance of the stack (jQMobile with these data layers) to be quite slow. The data fetching is OK but the rendering I'm not so happy with.