Friday, July 12, 2013

lawnchair : simple JSON storage

Persistent local storage is one of the areas where native client applications have held an advantage over web application. Cookies were invented early in the web’s history, and indeed they can be used for persistent local storage of small amounts of data. But they have three potentially deal breaking downsides:
  • Cookies are included with every HTTP request, thereby slowing down your web application by needlessly transmitting the same data over and over
  • Cookies are included with every HTTP request, thereby sending data unencrypted over the internet (unless your entire web application is served over SSL)
  • Cookies are limited to about 4 KB of data — enough to slow down your application (see above), but not enough to be terribly useful
Whats really needed is:
  • a lot of storage space
  • on the client
  • that persists beyond a page refresh
  • and isn’t transmitted to the server
What is Web Storage?
With HTML5, web pages can store data locally within the user's browser. Web Storage is more secure and faster. The data is not included with every server request, but used ONLY when asked for. It is also possible to store large amounts of data, without affecting the website's performance. The data is stored in key/value pairs, and a web page can only access data stored by itself.
A lawnchair is sorta like a couch except smaller and outside. Perfect for HTML5 web/mobile apps that need a lightweight, adaptive, simple and elegant persistence solution.
  • Collections. A lawnchair instance is really just an array of objects.
  • Adaptive persistence. The underlying store is abstracted behind a consistent interface.
  • Pluggable collection behavior. Sometimes we need collection helpers but not always.
  • Super micro tiny storage without the nasty SQL: pure and delicious JSON.
  • Default build weighs in at 3.4K minified; 1.5 gzip'd!
  • Adapters for any client side store.
  • Designed with mobile in mind.
  • Clean and simple API.
  • Key/value store ...key is optional.
  • Terse syntax for searching/finding.
  • Battle tested in app stores and on the open mobile web.
  • Framework agnostic. (If not a framework athiest!)
By default, Lawnchair will persist data using DOM Storage but if other adapters are available and DOM Storage isn't supported by the currently executing JavaScript runtime. Lawnchair will attempt each successive adapter until it finds one that works.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.