Cross Browser Client-Side Persistent Storage Without Cookies

PersistJS, a client-side JavaScript persistent storage library. Features include:

  • Small (9.3k minified, 3k gzipped)
  • Standalone: Does not need any additional browser plugins or JavaScript libraries to work on the vast majority of current browsers.
  • Consistent: Provides a consistent, opaque API, regardless of the browser.
  • Extensible: Custom backends can be added easily.
  • Backwards Compatible: Can fall back to flash or cookies if no client-side storage solution for the given browser is available.
  • Forwards Compatible: Supports the upcoming versions of Internet Explorer, Firefox, and Safari (Opera too, if you have Flash).
  • Unobtrusive: Capability testing rather than browser detection, so newer standards-compliant browsers will automatically be supported.

WHY

Why use PersistJS? What’s the problem with using cookies directly or simply requiring Flash?

Currently the only reliable cross-platform and cross-browser mechanism for storing data on the client side are cookies. Unfortunately, using cookies to store persistent data has several problems:

  • Size: Cookies are limited to about 4 kilobytes in size.
  • Bandwidth: Cookies are sent along with every HTTP transaction.
  • Complexity: Cookies are difficult to manipulate correctly.

Modern web browsers have addressed these issues by adding non-Cookie mechanisms for saving client-side persistent data. Each of these solutions are simpler to use than cookies, can store far more data, and are not transmitted along with HTTP requests. Unfortunately, each browser has addressed the problem in a different and incompatible way. There are currently 4 different client side persistent data solutions:

  • globalStorage: Firefox 2.0+, Internet Explorer 8
  • localStorage: development WebKit
  • openDatabase: Safari 3.1+
  • userdata behavior: Internet Explorer 5.5+

Some developers have attempted to address the client side storage issue with the following browser plugins:

  • Adobe Flash
  • Google Gears

The problem with relying on plugins, of course, is that users without the plugin installed miss out on the feature in question, and your application is dependent on software from a particular vendor. Google Gears, for example, is not widely deployed. Flash is, but it has problems of its own:

  • Many users block Flash or require a click in order to enable flash content; this makes Flash unsuitable as a transparent, client-side data store.
  • Flash is notoriously unreliable on newer 64-bit machines.
  • Some businesses block Flash content as a security measure.

Share your thoughts & feedback

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: