HTML5 localStorage Demo

While doing research about Apps vs. Web Apps, I misunderstood the capabilities of localStorage in HTML5.  I believed the data in localStorage would not persist once the device was powered down, but it turns out, that is not the case.

Building from some examples I found on web and Matthew David’s book on HTML5, I pieced together a localStorage Demo to test.

Here’s what I learned from the test:

  • HTML5 is not a complete spec
  • globalStorage is not yet available in Chrome (my preferred browser), so I backed the demo down to use localStorage instead.  I can’t comment on a material difference between the two, there is some documentation here.  I’m not even sure globalStorage is a part of the final spec, so localStorage will have to do.
  • The storage variables DO persist, even if the device is powered off
  • Clearing the browser cache will erase the local storage variables

I have not yet gotten too deep into the capabilites of the key-value pairs.  I would like to try adding different object types to the data to see just how robust local storgage can be.  As I have time to experiment, I will note what I learn here.

It appears there was another method of localized database storage using SQLite.  Safari, Chrome, and Opera seemed to be on board, but the folks over at Mozilla did not participate.  As a result, the spec has been dropped from HTML5 and, alas, the browser wars continue.

The current draft for robust, localized, SQL-like storage is the Indexed Database API as proposed by Oracle.  Currently, only Firefox 4 Beta and the latest Chromium builds seem to be partially supporting this spec.

You can test out the demo on this website here.

Comments are closed.