Mozilla

IndexedDB in Firefox 4

This is a guest post from Ben Turner, one of the developers of IndexedDB for Firefox.

Mozilla is pleased to announce support for IndexedDB in the upcoming Firefox 4 Beta 9 and recent trunk nightlies. IndexedDB allows web apps to store large amounts of data on your local system (with your explicit permission, of course) for fast offline retrieval at a later time. We’re hoping that webmail, TV listings, and online purchase history will one day be as convenient to access offline as they are online.

Web developers who are interested in using this new feature are encouraged to read the IndexedDB primer on Mozilla Developer Network. The primer attempts to strip away some of the complexity in the specification, to discuss the most important concepts and provide simple examples. The truly hardcore are of course welcome to read the entire specification.

Keep in mind that IndexedDB is brand new and is not uniformly supported by all browsers, and please file bugs for any behavior that seems to contradict the specification!

11 comments

Comments are now closed.

  1. Josh wrote on January 12th, 2011 at 11:49:

    Are these databases synced on Firefox Sync? If not, are there plans to do this in the future?

  2. oxdef wrote on January 12th, 2011 at 14:37:

    Why not HTML5’s Web SQL Database?

  3. Janet Swisher wrote on January 12th, 2011 at 14:55:

    @oxdef: This earlier post on database APIs addresses that question. While the code in Firefox 4: An early walk-through of IndexedDB is now obsolete, it gives an idea of the differences in approach.

  4. treebat wrote on January 12th, 2011 at 22:52:

    oxdef, it was for religious and petty reasons. it’s long been a done deal, though, and perhaps it would be wise for developers who want a powerful cross-platform client-side DB soon to write and/or use a library that abstracts both IndexedDB and Web SQL Database.

  5. anonymous wrote on January 13th, 2011 at 11:48:

    Can it be deactivated or better, removed? I do not want another persistence layer, than the cookie store!

    1. alexleduc wrote on January 18th, 2011 at 13:14:

      If you are using private browsing, the feature is disabled.

  6. alexleduc wrote on January 18th, 2011 at 13:25:

    What I don’t understand is the difference between using that and local/gloabalStorage. Weren’t those intended for offline web apps to store data? Doesn’t having IndexedDB and this create 2 APIs to do the same thing?

    1. Dan wrote on January 19th, 2011 at 13:34:

      The difference is in storing related data. With a key/value storage you’d have to pre- or postfix your variables to create some token relationship. With a DB you have tables with columns and rows, so storing and retrieving data is easier and standardized.

      1. alexleduc wrote on January 20th, 2011 at 05:53:

        The IndexedDB primer linked in this article says “IndexedDB databases store key-value pairs.”

        1. Dan wrote on January 21st, 2011 at 15:29:

          Eventually, yes. I admit I wasn’t completely on the point there.

          IndexedDB lets you store whole JS objects in databases, which each can have multiple key/value pairs stored within them. That gives you a means to group related data, and the indexing gives you a means to query the data. So it’s actually more like CouchDB than relational databases like MySQL for example.

          You could store objects with g/l storage, too, if you’d convert them to JSON for example (since everything is a string in g/l storage). But you couldn’t query it like you could with IndexedDB.

          1. alexleduc wrote on January 22nd, 2011 at 05:31:

            Thanks for the clarification.

Comments are closed for this article.