Extension development: Difference between revisions
(→Extension technologies: +PyXPCOM) |
m (→Tutorials: link update) |
||
Line 26: | Line 26: | ||
* roachfiend.com has a [http://roachfiend.com/archives/2004/12/08/how-to-create-firefox-extensions/ HowTo] that walks through the entire extension development process. The tutorial covers creating extensions for Firefox 1.0 and later versions. (Some content is Windows specific.) | * roachfiend.com has a [http://roachfiend.com/archives/2004/12/08/how-to-create-firefox-extensions/ HowTo] that walks through the entire extension development process. The tutorial covers creating extensions for Firefox 1.0 and later versions. (Some content is Windows specific.) | ||
* There are a few tutorials about creating extensions for Firefox 1.5: [[Getting started with extension development|in this knowledge base]] and [http://developer.mozilla.org/en/docs/Building_an_Extension on Devmo]. | * There are a few tutorials about creating extensions for Firefox 1.5: [[Getting started with extension development|in this knowledge base]] and [http://developer.mozilla.org/en/docs/Building_an_Extension on Devmo]. | ||
* There is a minimal [http:// | * There is a minimal [http://yergler.net/blog/2004/05/20/writing-mozilla-extensions/ example extension] available at yergler.net. | ||
* [http://www.orablogs.com/duffblog/archives/000536.html Brian Duff's Hello World tutorial]. | * [http://www.orablogs.com/duffblog/archives/000536.html Brian Duff's Hello World tutorial]. | ||
* [http://www.borngeek.com/firefox/tutorial/ Jonah Bishop's Firefox Toolbar Tutorial] — creating toolbar extensions (like WebDeveloper or Googlebar) for Firefox. | * [http://www.borngeek.com/firefox/tutorial/ Jonah Bishop's Firefox Toolbar Tutorial] — creating toolbar extensions (like WebDeveloper or Googlebar) for Firefox. |
Revision as of 15:47, 31 December 2005
This page is part of the extension development documentation project.
Ask your questions in MozillaZine Forums. Also try browsing example code.
Note: development documentation is in process of being moved to Mozilla Development Center (MDC).
Introduction
Extensions allow programmers to add new features to Mozilla applications or allow existing features to be modified. Typically, extensions modify the “chrome” of their target application—the user interface and the scripts that add functionalty to that interface. However, it is also possible for extensions to include compiled code in the form of XPCOM components.
Extension technologies
You will almost certainly need to use the following technologies, although it is not necessary to be an expert in them. You may be able to pick up much of what you need just by examining the source code for other extensions.
- XUL (XML User-Interface Language). Used to define the onscreen layout of the UI and to attach scripts and style to the interface.
- JavaScript. The primary scripting language in Mozilla and the language in which most extensions are written.
- DOM (Document Object Model). Used to manipulate XUL in real-time as well as any HTML documents loaded.
- XPCOM/XPConnect. Mozilla packages together useful functions into XPCOM (Cross-Platform Component Object Model) components, which may then be accessed from external code, including JavaScript via XPConnect. This allows the extension developers access to the preferences database, the filesystem, and many other pieces of Mozilla technology (Extensions can be written in JavaScript, C++, or even Python with PyXPCOM).
- CSS (Cascading Style Sheets). Used to style the interface and to attach XBL bindings to XUL documents.
More advanced extensions may require the following technologies.
- XBL (XML Binding Language). Used to extend XUL, allowing the creation of new types of widgets and associated behaviors.
- RDF (Resource Description Framework). Used as a data-storage format in some parts of Mozilla and in some extensions.
Getting started
Setting up your environment
- Please see Setting up extension development environment for development preferences you can set and extensions you can install. It also contains information about running a separate instance of Firefox using a development profile.
- Getting started with extension development contains tips on easily setting up extensions development environment in Firefox/Thunderbird 1.5 (so that you no longer have to recreate the JAR and/or XPI files each time you make a change in your extension). It is also a quickstart guide containing useful links for beginners and the obligatory helloworld extension, which can be used as a basis of your extensions.
Tutorials
There is a variety of tutorials available which will help with general extension development or with learning specific technologies. You don't have to read all of them before starting hacking.
- XULPlanet (mirror) is the premier resource on the internet for XUL and XPCOM. It contains an extensive tutorial which will walk you through XUL.
- roachfiend.com has a HowTo that walks through the entire extension development process. The tutorial covers creating extensions for Firefox 1.0 and later versions. (Some content is Windows specific.)
- There are a few tutorials about creating extensions for Firefox 1.5: in this knowledge base and on Devmo.
- There is a minimal example extension available at yergler.net.
- Brian Duff's Hello World tutorial.
- Jonah Bishop's Firefox Toolbar Tutorial — creating toolbar extensions (like WebDeveloper or Googlebar) for Firefox.
- mozilla-firefox-extension-dev.blogspot.com — various information on extensions development.
- thunderbirddocs.blogspot.com — various information on Thunderbird extension development.
- Signing an XPI by Pete Collins.
- Creating a Mozilla Extension is a document on mozilla.org which walks through the process of creating a simple extension. It has a particularly useful section on XUL Overlays which enable modifications to existing chrome without editing the existing file. However, it has not yet been updated to cover the new packaging system.
Books
As well as web resources, there are a couple of books available describing Mozilla technologies and their usage. Both books cover a comprehensive range of Mozilla technologies. They are available both online and in a more user-friendly dead-tree format.
- Creating Applications With Mozilla. O'Reilly's reference, released at about same time as Seamonkey (the Mozilla suite) 1.0 and avaliable online as a collection of HTML files.
- Rapid Application Development With Mozilla. Available as a set of compressed PDF files, and more up-to-date and more detailed than the O'Reilly offering. Also available as a collection of XHTML pages.
Getting finished
To make your extension available to others, you need to package it as XPI and release it (make sure you thoroughly test it first!).
Making it better
- Be sure to make your extensions localizable: Use DTDs for XUL and properties for scripts.
- Themes apply CSS using various selectors, particularly based on
id
andclass
attributes on your elements. Include these to make theme development easier. - Try to follow the set of Extension guidelines. This can help to make all extensions act predictably, which increases usability.
Further Information
Local resources
Example code
- Example Code. Common development tasks and techniques.
- Example Extensions. Extensions that provide a clear demonstration of a particular technique or function.
Coding style
- Javascript coding guidelines.
- Cross-Version Compatibility Techniques for Extensions. (Currently applies to Mozilla 1.7.x / Moz 1.8.x only.)
Development fundamentals
- General advice for extension development, including how to avoid rebuilding JAR files and how to correctly register overlays.
- XML namespaces. Why http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul is at the top of every XUL document.
Troubleshooting
File locations
- Chrome URLs. Discover the location within the installation folder of the chrome you wish to overlay.
Other resources
- Mozilla development resources
- A few mozilla.org documents about extensions/themes
- Extensions section of Devmo
Getting help
- MozillaZine provides a Development forum which is the place for technical questions and an Extensions forum which occasionally has technical discussion but is more useful for releasing extensions to get testing and feedback.
- The netscape.public.mozilla newsgroups are the official location for code-related queries. They are particularly useful if you're implementing an XPCOM component or have a question that MozillaZine posters can't answer. See the developer forums page for a description of each newsgroup.
- IRC (see also this). Live Developers! Get satisfaction online from red hot developers! (Note: this is not a dating service.)
Get involved
- Take a look at Dev : Project ideas to see the list of requested extensions.
- Help maintaining the Extension development knowledge base. Post your tips and code snippets for others to use. (You may use the MozillaZine forums (preferably Development or Extensions) to discuss the tips.) Also consider helping the Devmo project.
- Contribute to existing extensions.
- List ideas at (or borrow ideas from) AllYourIdeas extension category