We are planning to deprecate the use, in Firefox, of the techniques described in this document.
Don't use these techniques to develop new add-ons. Use WebExtensions or the Add-on SDK instead.
If you maintain an add-on which uses the techniques described here, consider migrating it to use WebExtensions or the SDK instead.
Add-ons developed using these techniques might not work with multiprocess Firefox (e10s), which is already the default in Firefox Nightly and Firefox Developer Edition, and will soon be the default in Beta and Release versions of Firefox. We have documentation on making your add-ons multiprocess-compatible, but it will be more future-proof for you to migrate to WebExtensions or the Add-on SDK.
A wiki page containing resources, migration paths, office hours, and more, is available to help developers transition to the new technologies.
Draft
This page is not complete.
This document was authored by Hideyuki Emura and was originally published in Japanese for the Firefox Developers Conference Summer 2007. Emura-san is a co-author of Firefox 3 Hacks (O'Reilly Japan, 2008.)
Introduction
If you're reading this guide, you’ve probably used Firefox before. Perhaps the first time you looked at Firefox, you may have been surprised to see that it has a much simpler structure than other full-featured browsers, such as Opera or Safari.
What features are considered standard for web browsers these days? Perhaps things like fine-grained tab controls, mouse gestures, extensive toolbars and buttons, a feed reader, integration with a variety of web applications, or sophisticated tools to assist with web design. But we didn't set out to create an all-in-one browser that can satisfy everyone.
Instead, Firefox can support these features through extensions. The core browser is limited to basic features, so it’s something that a beginner can be comfortable with, but users who want something beyond that can install extensions.
About extensions
Management using the Add-ons Manager
Firefox's Add-ons Manager is an excellent way to manage extensions, and is a great step up in ease of use.
The Add-ons Manager handles the following tasks:
- Safely installs and uninstalls add-ons
- Makes sure add-ons are compatible with the version of Firefox you're using
- Manages a whitelist of sites trusted for installing add-ons
- Helps troubleshoot add-ons by disabling them and offering a safe mode
- Confirms and runs updates
- Provides access to add-ons' settings dialogs
- Provides access to add-ons' support sites
Development environment amenities
Initially, there wasn't adequate documentation available, and extension developers were largely left to fend for themselves1; however, now there's a considerable store of knowledge.
Because Firefox and its extensions are designed to support multiple languages, excellent extensions come from all over the world, and can be quickly localized by anyone interested.
This lowers the threshold both to using and to developing extensions; that fact, combined with Firefox's rapidly growing popularity, has created a positive feedback loop, with the number of extension users and extension developers growing explosively—there are now more than 7000 extensions and themes published at the Firefox Add-ons site (https://addons.mozilla.org).
What you can do with extensions
Let's look at what features extensions can add, and some actual examples of extensions.
Single feature extensions
FIXME: Update this.
These are relatively simple extensions that add a single feature.
- Text Link
- Makes it so that double-clicking on an unlinked URL follows that URL.
- Undo Closed Tabs Button
- Adds a toolbar button to re-open the most recently closed tabs to the History menu.
- Locationbar
- Separates a URL’s domain and path in the location bar for easier reading.
Feature enhancing extensions
FIXME: Update this.
These extensions enhance features that already exist in Firefox.
- Tab Mix Plus
- Offers detailed tab-related settings.
- PrefBar
- Gives access to numerous preferences from the toolbar.
- NoScript
- Enables and disables JavaScript execution on a site-by-site basis.
Web application integration extensions
FIXME: Update this.
The use the APIs of certain web applications to provide certain pieces of information.
New feature extensions
FIXME: Update this.
Extensions can add completely new features to Firefox. This class of extension requires a greater level of knowledge and programming ability.
- GreaseMonkey
- UserChrome.js
- Both of these provide an environment for running user scripts (JavaScript) in Firefox itself, where the scripts can target specific websites.
- Adblock Plus
- Blocks the display of unwanted advertisements on web pages.
- All-in-One Gestures
- Adds mouse-gesture functionality.
Application level extensions
FIXME: Update this.
These are sophisticated extensions that can be considered full-scale applications in their own right, essentially using Firefox as the development platform.
One-trick gag extensions
FIXME: Update this.
There are a number of one-trick gag extensions that aren’t very useful.
This is a very brief survey of a few extensions, but there are many other unique extensions available.
Table 1: Advanced customization methods for Firefox
Customization Method | Does it work for web sites? | Does it work for Firefox? |
User style sheets (change appearance through CSS) |
Yes; you can change the |
Yes; you can change the |
User scripts (change appearance and functionality through JavaScript) |
Yes; you can use the GreaseMonkey extension or "bookmarklets." |
Yes; you can change |
Extensions (these can do anything) | Yes | Yes |
Theming (this changes the look of the browser) | No | Yes |
Let's build an extension
Table 1 shows the various customization options available to a user in Firefox. Users have flexible customization options, using CSS in user style sheets and JavaScript/DOM in user scripts (these depend on Stylish, GreaseMonkey, and userChrome.js
).
In addition to CSS and JavaScript, extensions can take advantage of XUL and XPCOM technologies for more sophisticated features. Themes, which alter Firefox's appearance, are a kind of add-on.
In order to create an extension, you need an idea and just a little programming ability. The following chapters explain in detail the extension-writing techniques of some of Japan's leading extension authors. We encourage you to try your hand at it as well.