Deploying a Plugin as an Extension

One of the new features available in Firefox 1.5 is the ability to place browser plugins in a Firefox extension. This feature is particularly useful for vendors who wish to deploy the plugin even if Firefox is not currently installed, or who want to use the automatic extension update mechanism to update their plugin to a newer version.

Historically, most people have chosen to use an install.js script to install a plugin. When this method is used, you can choose to either place the plugin into the plugins directory, or, on Windows, place it into your own directory and modify the Windows registry to let Firefox know where to find the plugin. The downside to this method is that once the plugin is installed, it might be difficult for users to upgrade, uninstall, or disable the plugin.

With Firefox 1.5, you can use the built-in extension mechanism to make a plugin available to your users. This allows the plugin to be treated like other Firefox extensions; it can be upgraded, disabled, or uninstalled using the Firefox user interface.

In this article, we will create an extension for the Rhapsody Player Engine. Normally, this plugin is installed in a local directory, and a registry item is used to let Firefox know about the plugin.

First, let's take a look at the structure of the XPI file used for a browser plugin.


The important file here is the install.rdf file. This contains information about our extension; all extensions have one. Here's what a basic install.rdf file looks like:

<RDF xmlns=""
  <Description about="urn:mozilla:install-manifest">
    <em:name>Rhapsody Player Engine</em:name>



You can get more detailed information about this file at install.rdf.

We'll cover the basics.

The id specifies a unique ID that uniquely identifes this extension of the form. If you have written extensions for Firefox in the past, you'll notice that we no longer require the use of GUIDs as extension IDs.

The name specifies the name of the extension that appears in the extension manager.

The version is used for version checking when we are updating extensions.

The targetApplication section specifies that platform we want to work on (that ID is for Firefox). It also specifies what versions of Firefox we want to work with.

Now that we have an install.rdf file, we can actually package the XPI. Simply use the ZIP utility to create the XPI file. Make sure you keep the directory structure!

Now we can open the XPI in Firefox and it will get installed. You'll have to restart Firefox so the plugin will be available.

After restarting Firefox, the extension manager will include an entry for the Rhapsody Player Engine. Because it is an extension, we can disable/enable it, as well as uninstall it.

You'll notice that one thing we did not do is provide a mechanism for updating the plugin, as discussed at the beginning of this article. Let's cover that now.

One of the additional things that can be placed in the install.rdf is called an updateURL. For example:


This URL specifies an RDF file that can be used to tell Firefox that there are updates available for your extension. This RDF file can be updated to indicate that an update to our extension/plugin is available.

Finally, if you want to package plugins for multiple platforms into a single extension, you can do that as well. There are two ways to do this.

First, you can simply put all the files in the plugins directory. Firefox will load the correct plugins based on the platform, simply because the plugins for other platforms won't load.

If your plugin is for Windows, don't forget add to version resources to your plugin's DLL. Also, supply MIMEType and FileExtents, without these your plugin won't work.

Michael Kaply
Firefox Advocate