Setting up persistence.js in the browser

Browser support

  • Modern webkit browsers (Google Chrome and Safari)
  • Firefox (through Google Gears or in-memory database and localStorage fallback)
  • Opera
  • Android browser (tested on 1.6 and 2.x)
  • iPhone browser (iPhone OS 3+)
  • Palm WebOS (tested on 1.4.0)


To use persistence.js you need to clone the git repository:

git clone git://

To use it you need to copy lib/persistence.js to your web directory, as well as any data stores you want to use. Note websql stores both depend on the sql store. A typical setup requires you to copy at least lib/persistence.jslib/ and lib/ to your web directory. You can then load them as follows:

<script src="persistence.js" type="application/javascript"></script>
<script src="" type="application/javascript"></script>
<script src="" type="application/javascript"></script>

If you want to use the in-memory store (in combination with localStorage) you also need the included.

Setup your database

You need to explicitly configure the data store you want to use, configuration of the data store is store-specific. The WebSQL store (which includes Google Gears support) is configured as follows:, 'yourdbname',
                                'A database description', 5 * 1024 * 1024);

The first argument is always supposed to be persistence. The second in your database name (it will create it if it does not already exist, the third is a description for you database, the last argument is the maximum size of your database in bytes (5MB in this example).

You’re now ready to start using persistence.js!

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *