Find file
Fetching contributors…
Cannot retrieve contributors at this time
89 lines (50 sloc) 2.95 KB



StorageJS is a micro wrapper for client side persistent storage. It is explicitly aimed at mobile devices (but can be used for desktop apps, too, of course).

StorageJS uses the EmbedJS approach. That means:

  1. It is divided into features, and for these features exist different implementations (based on the targeted storage engine).
  2. You have different output builds for the different storage backends. There is branching on run time.

That way, you have the smallest possible footprint for your project, and deliver only the code that you really need for your project.

Supported Storage Engines

StorageJS supports localStorage, Widget preference store, Gears, userData behavior and Cookies. Due to the fact that StorageJS provides sync read access to storage, there's no support for Sqlite impls.


The base feature, "engine", exposes the follwing methods:

var value = storage.get(key);

storage.set(key, value);


Both key and value MUST be strings.

The other features add more methods, such as clear(), getAll() or getAllKeys(), or modify given methods. Please refer to the README in each feature's directory to learn more about what it does.


To create a build specific to your project, you can cherry-pick whatever features you need and create a profile. However, some default profiles that cover the most use cases are already pre-defined. Inside of the "builds" directory are ready made builds you can use out of the box.

To build your custom profile, you need the EmbedJS build tool. You can get it from github. Next, you need to modify the build-config.json file. It's well commented, so don't hesitate! Finally, run the shell script to create your builds.

# Clone the repos
> git clone
> git clone

# trigger the actual build using the embedjs-tools bash script
> cd StorageJS
> ../embedjs-tools/ profile=YourCustomProfile

Size matters

The minimal profile, containing the base feature "engine" (providing the get/set/remove methods), results in builds of the following size (not gzipped):

storage-minimal-behavior.js          622b
storage-minimal-cookie.js           1351b
storage-minimal-gears.js            1474b
storage-minimal-localStorage.js      187b
storage-minimal-widget.js            306b

The full profile, including the features getAllKeys, getAll and clear (providing the methods getAllKeys(), getAll() and clear()), results in builds of the following size (not gzipped):

storage-full-behavior.js            1157b
storage-full-cookie.js              1626b
storage-full-gears.js               1996b
storage-full-localStorage.js         509b
storage-full-widget.js              1677b


Please see each feature's own Readme file, located in their respective directories.