This is an archived page. It's not actively maintained.

Simple Storage

The namespace provides an easy way to persist data across browser restarts. It's a simple key-based persistent object data store.

Simple storage is really simple. is a single, persistent JavaScript object private to each jetpack. For the most part this object is like any other JavaScript object, and a jetpack can set whatever properties it wants on it. To manipulate its persistent data, a jetpack therefore need only use the various standard JavaScript functions and operators.

The object is automatically and periodically flushed to disk. How and when it is flushed is an implementation detail. Jetpacks can flush it manually, however, by calling The object can also be forced to reload its data from disk by calling, although the data comes loaded automatically. Don't abuse these methods, since they cause Firefox -- all of Firefox -- to drop what it's doing to make a trip to the disk. If you call them too often, Firefox may become unresponsive for some of your users. Unless you are doing something strange, let Jetpack flush your data for you.

The namespace currently lives in the future and must be imported before it is used:



sync()As described above, the object is automatically written to disk, but a feature may force flush by calling Don't abuse this method.
open()As described above, the object is automatically populated when a feature is loaded, but a feature may force the object to read from disk by calling Don't abuse this method.


This code persistently stores some data:

var myStorage =;
myStorage.fribblefrops = [1, 3, 3, 7];
myStorage.heimelfarbs = { bar: "baz" };

And this code -- pretend it's in the same jetpack as the code above -- simply uses that data:

myStorage.fribblefrops.forEach(function (elt) console.log(elt));
var bar =;;

That's all there is to it! Note that these examples create a myStorage variable to emphasize the fact that is just a normal JavaScript object. They could have simply used directly.

Here's a complete real-world example. It's a simple note-taking jetpack. Select some text on the page, right-click, and select Note. The text will be remembered across browser restarts as a note. All notes are shown in the Tools menu. You can install this example from the Jetpack Gallery.


// Create the persistent notes array if it doesn't already exist. = || [];
var notes =;

// Updates the Jetpack menu with the current notes.  We'll add a Notes menu with
// a submenu, which lists all the notes.  If there are no notes, we'll show a
// disabled "(Empty)" menuitem.
function updateJetpackMenu() {{
    label: "Notes",
    menu: new jetpack.Menu(notes.length > 0 ?
                           notes :
                           [{ label: "(Empty)", disabled: true }])

// Modify the page's context menu by sneaking in before it's shown.  If there's
// a selection, add a Note menuitem that makes a new note.  Otherwise, don't
// modify the menu at all.  We'll limit the number of notes to 20.  Old notes
// will be forgotten. :( = function (menu) {
  if (jetpack.selection.text)
      label: "Note",
      command: function () {
        if (notes.length > 20)

// Initialize the Jetpack menu with the current notes.

See Also