How to create restart-less #Firefox4 extension *WITHOUT* Jetpack
On Firefox 4, users can install and uninstall Jetpack extensions without a browser restart. The traditional extensions are needed for a browser restart.
Jetpack is not required
Jetpack itself does not provide the restart-less feature. Jetpack SDK is a rich development environment for Restart-less extensions (which are called by Bootstrapped extensions).
To make a bootstrapped extension, you need:
- add the
em:bootstrap="true"
in install.rdf; and - add bootstrap.js
Hello world of bootstrapped extensions
Step1. Write install.rdf with em:bootstrap="true"
There is no difference from traditional extensions... Only one exception is to add em:bootstrap="true"
.
Step2. Write bootstrap.js
This file shall contains entry point functions : install(data,reason)
, startup(data,reason)
, shutdown(data,reason)
and uninstall(data,reason)
.
This extension says "Hello world." after it is installed and/or enabled, and "Good bye." after it is uninstalled and/or disabled.
Above code is very very simple. bootstrap.js in the general bootstrapped extensions (for example Jetpack) are complexity.
Step3. Packaging
All you have to do is compress the files.
Open the XPI file to install. As soon as it is installed, a following dialog is displayed.