Jon Rumsey

An online markdown blog and knowledge repository.


Project maintained by nojronatron Hosted on GitHub Pages — Theme by mattgraham

Notes on an External Article at diveinto.html5doctor.com

HTML5 Dr. on Local Storage For Web Applications

Overview

Desktop Apps have had advantage over web apps, where there are plenty of storage possibilities and if the right one does not already exist, a desktop app developer can invent one.

WebApps have been stuck with cookies:

WebApps want more storage space, that persists between browser refresh, and is not transmitted to the server.

Hacks Before HTML5

MSFT introduced DHTML userData in Internet Explorer which held up to 640K. Flash Cookies (Local Shared Objects) came next.
Brad Neuburg created AMASS (AJAX Mass Store System) to initeroperate with LSO, and later updated it to work with javascript (DOJO).
Google added a browser plug-in "Gears", an API for an embeded SQLite instance.
DOJO was updated to be a super-API for all these, called DOJOX.

LocalStorage nowadays is either:

  1. Tied to a specific browser, or
  2. Provided only through a 3rd party plug-in

Introducing HTML5 Storage

HTML5 Storage == Web Storage == LocalStorage == DOM Storage

but not all necessarily equal, rather, similar.

HTML5: KVP storage in the browser, similar to cookies. Survives refresh and browser or tab closure. Never transmitted across the wire. Available in all modern browsers.

Detecting HTML5 Storage

Options:

Using HTML5 Storage

KVP Keys are strings.
KVP Values can by any JS Object type, but is stored as a string (in the end).
Calling 'set' to an existing Key will overwrite whatever value is already stored there.

Tracking Changes to HTML5 Storage Area

A DOM 'storage' event could be fired if any of the following actually make a change:

setItem() removeItem() clear()

The storageEvent object can report:

All are non-cancellable.

HTML5 Storage Limitations in Current Browsers

HTML5 Storage in Action

There are some rules to remember and good things to do when interacting with HTML5 Local Storage:

Beyond Named KVPs

Google Gears inspired Web SQL Database spec, or "WebDB".
Enables simple js access to a local SQLite DB layer:

openDatabase();

obj.executeSql("sql_statement");

Yes, that's right, Select, Update, Insert, and Delete statements are supported.

Web SQL DB Support

WebSimpleDB

AKA 'Indexed Database API' AKA 'IndexedDB'.

However it is not structured:

IndexedDB does not enjoy support across all browsers.

References

The article itself has a vast number of references to HTML5 Storage, WebSQL, IndexedDB, and the history of persistent storage in browsers.
A side comparison of IndexedDB and Web SQL Database

Back to index in readme