Building an Extension

Please use the Extensions forum at MozillaZine for general discussion; only put comments about this particular article on this page.

Requires updating to use addon-bar instead of statusbar

This article requires updating to use the addon-bar instead of the the statusbar in the the example. trevorh 06 June 2011

Maybe add some trouble shooting

It's a great article. In fact, I was able to understand most, if not all of the theory. Only problem is it doesn't work. Though I did some small customizations, I came back later and tried again going 100% to the example. Even using C:/extensions/myExtension/ as the folder. Still ceases to work, even when I check the chrome directory via Firefox. So maybe an idea would be to add some trouble shooting to this article? It would help out the slow learners such as myself. --TDC

It is true. Great explanation. Bad execution :S. --SaberGun 02:40, 10 October 2006 (PDT)

I struggled to get this to work as well. Here is my mistake explained: I got an error using C:\extensions\my_extension\ as the root folder and as the file in my profile extensions folder. The content of the file was C:\extensions\my_extension\ To make it work I changed the name of the C:\extensions\my_extension\ folder to C:\extensions\ I also changed the content of the file to C:\extensions\

Warning: the extension redirect file won't work if the folder name contains an underscore. That's probably why "my_extension" doesn't work. --mattatmilsoft

Please remove the underscore from the folder name.

What's the point?

As far as I can tell this tutorial does not work. Multiple people have commented on this fact. Despite seeing those comments I painstakingly followed the procedures myself hoping it was merely a procedural problem. I had no luck. Any chance of somebody coming in and fixing this introductory tutorial? I'm tempted to make a little script so it can be more easily recreated so others can quickly try, verify the problem, and fix it. Would that help?

Try joining #extdev on and getting people to help you. After the problem is fixed, we can see if there's a problem with the article and fix it as well. --Nickolay 16:21, 18 August 2007 (PDT)

Divergence point

This paragraph

 The browser window is: chrome://browser/content/browser.xul Try typing this URL into the location bar in Firefox!

is doable. However what are we suppose to be seeing here? I typed that in and I got something that looked like my Firefox header within the browser. Is this what we are suppose to see? An explanation would be great to know we are still following the explanation correctly.

You're supposed to see a half-functioning browser in a tab. Loading it in content like this is not supported, but it does demonstrate that the browser.xul URI is associated with the main browser UI. --Nickolay 16:05, 18 August 2007 (PDT)

Poor description of the email address

This paragraph

* - the ID of the extension. This is some value you come up with to identify your extension in
 email address format (note that it should not be your email). Make it unique. You could also use a GUID.  NOTE:
 This parameter MUST be in the format of an email address, although it does NOT have to be a valid email address.

leaves the user thinking why would you ever mention an email address if you are not going to be using it. Surely the intent is to use an email address where the author can be contacted. If this is not the case then an explanation needs to be supplied why it is not and how to supply something that looks nothing like an email address.

The intent is not to provide a point of contact. The id just needs to be unique among all the extensions. You can of course use your e-mail as the extension's id, but that would not be right, because the e-mail address identifies you, not the extension. (What would you do if you had two extensions?) --Nickolay 16:11, 18 August 2007 (PDT)

Extension Builder: Support

I think it would be worthwhile to add a section which explains how to do this all with Extension Builder. As it makes editing speedier, and easier.

I'd do it, but I am still learning.. lol. --SaberGun 02:48, 10 October 2006 (PDT)

Downloadable template

Is there a downloadable extension template available? That would really help would-be extension authors... --Maian 03:07, 9 October 2005 (PDT)

There's one from another similar article: --Nickolay 12:15, 9 October 2005 (PDT)

No Hello World! in the status bar?

I followed the directions but the status bar didn't change. I already had a number of extensions installed, and I found the source of the problem. If you have a similar problem, change the id="my-panel" line in status.xul to something else, like id="my-panel123". Then everything should be fine. --Brett

Digital finger print readers extension

I am not a programmer and was wondering if I could rally some support to have an extension written so users can operate digital finger print readers within Firefox? This last convenience is the only thing still keeping me tethered to Explorer. vehlewa1 7:45, 3 December 2005 (EST)


Could someone elaborate a little more on what this means? "window is the localName value of the root element of the XUL document..." Where else, for example, does the corresponding word window also appear? I don't see how it is chosen. --Randomandy 06:00, 2005 October 11 (PDT)

It means the part of the tagname excluding the namespace prefix (if it exists) of the document's root element. So if you have some document that looks like <?xml version="1.0"?><xul:dialog xmlns:xul="(xul namespace)">...</xul:dialog>, dialog would be the localName of the root element. If it were just <dialog>...</dialog>, the localName would still be dialog. At least, that's what I think it's saying. I'm not familiar with XUL. --Maian 06:43, 11 October 2005 (PDT)


It's good that this article encourages the use of a locale file, but it doesn't really tell you where to put your locale file or how to write an entry for it in your manifest. Perhaps a snippet like the following under Create a Chrome Manifest?

locale    sample    en-US    chrome/chromeFiles/locale/en-US/

--Ox336699 13:54, 5 November 2005 (PST)

Some problems

I tried this article out with a freshly downloaded 1.5 Firefox, but it didn't work. I don't get any errors in the javascript console window. I poked around on the DOM inspector in chrome://browser/content/browser.xul and found the statusbar element that was supposed to be overridden, but I don't see my sample item in there. If I visit my element (which I named fetch rather than sample) at chrome://fetch/content/fetch.xul, I see the 'hello world' content displayed in the inspector's window. It's almost as if the file I created in my profile's extension directory isn't being slurped up. Is there a way to tell if this happened or not?

[Edit:] Ah.. missed one of the 'sample' search & replaces in the chrome.manifest file. I needed to open fetch.xul, but was attempting to open sample.xul instead. Didn't see any warnings or anything, so that's what got me. I'm up and running, now, though.

--jrjbertram, 2:30 pm 4 December 2005


From javascript within the extension, how does one read its version? Using InstallTrigger.getVersion('') does not work.

The InstallTrigger used to work if you supplied an install.js file with the xpi. It is now gone with firefox 3, so the question still remains.

--Kurt, 2005-12-21 23:40:00-05

Callek's change to wording

Callek, this change doesn't make sense to me (you forgot to change some punctuation at least). I like the 'go back' variant more fwiw. --Nickolay 08:41, 11 January 2006 (PST)

Sure, I am by far not the best english writer (even though it is my only language). At the time the way it initially was I liked best, so I changed that back. Now though it appears like the 'go back' variant was more comprehensive. Feel free to revert my change at your whim. --Callek 17:22, 11 January 2006 (PST)

What do I use for context menus?

If I wish to add a context menu item to a scpeific element, how would I go about it? What I want is a simple extension for decoding postdata. You right-click on a submit button and have an option that will show the postdata as it would be submitted i.e. first run the form's onsubmit javascript command then output the data as it would be submitted. Also, I would I go about calling the function and viewing the page items? Coppro 16:57, 25 January 2006 (PST)

Please see Extensions:Community Particular the Mozilla Zine Forums link(s). You will find much more help for what you want than on developer documentation Talk Pages. --Callek 22:03, 25 January 2006 (PST)


Just noticed. The added images are not from the extension that is constructed in this tutorial, but from the mozillazine helloworld. I guess including them on this page is quite confusing. --Nickolay 16:02, 15 February 2006 (PST)

Nickolay, allow me to recommend removal of those Images from this article until they are updated to reflect what is actually in this article. --Callek 17:02, 16 February 2006 (PST)

Until the part the part Tests, this article only explain how to create a basic extension and put a text in the status bar panel, but this image shows hello world in the Tools menu, so the guy who don't get it can think that he has done a mistake because he don't got it. (unsigned, by User:Omnisilver, 21 August 2006)

I've gone ahead and removed the images, they do nothing but cause confusion. --04:11, 25 August 2006 (PDT)


Command line handlers section

I commented out the section about command line handlers for three reasons:

  1. Vast majority of extensions don't use command handlers. Chatzilla is not a typical extension, it's a XUL app with hooks into Firefox UI.
  2. "Building an Extension" is an introductory tutorial aimed at people new to extensions or perhaps to Mozilla platform in general. Since CLHs are not essential to extensions, we don't have to put it on this page.
    There is a doc (sort of) on command line handlers, and it can/should easily be found via categories or search facility. If the topic of CLHs is considered to be important enough to beginner extension authors, we could link to that document.
  3. The section in question doesn't actually explain anything. It tries to cover the component registration code and the command line handlers in four sentences. This is not useful. Simply linking to the document about creating XPCOM components and/or about CLHs would be much more efficient.

--Nickolay 18:04, 10 March 2006 (PST)

Nickolay, I would like some mention of commandline handling, even if just a sentence about if your extension wants to handle commandline params, please read the Chrome:_Command_Line doc. Handling is good for all sorts of extensions; almost any extension that provides a separate window should be encouraged to provide a command-line accessor like -jsconsole -inspector etc. --bsmedberg 18:02, 14 March 2006 (PST)
Okay, I edited the article. --Nickolay 04:52, 15 March 2006 (PST)

Tweaked the Test Section

I'm new here, but FYI: I added a new clause to the Test section. As written, it was slightly inaccurate (and led to some head-scratching on my part), because it implied you should leave your overlay in place (somewhere other than in your profile folder) and could just point to it. But that's not quite true, AFAICT: you need to adjust the chrome.manifest accordingly, so that it actually points to the overlay, rather than pointing into the chrome directory.

Feel free to override me and rewrite if I'm missing something here, but I figured I should pass on the clarification while I thought of it. -- Mark "Justin" Waks 3:26, 12 April 2006 (EST)

You're confused a bit. It's the content, locale, and skin instructions that point to the physical location of extension files. When you specify an overlay using the overlay instruction, you don't mention the physical locations - the chrome:// part of URI means that Gecko should use the chrome registry to find the specified resource (see Chrome Registration for more information about that).
If you still don't get it, feel free to ask additional questions on mozillazine forums or on IRC, and someone will help you. --Nickolay 14:02, 12 April 2006 (PDT)


I think this document should explain how several skins can be used within an extension. I personaly don't know how to do it. -- Regis Decamps 15:17, 25 September 2006 (PDT)

There are no built-in ways to do that and it's definitely out of scope of this document. Ask in a newsgroup (detailed question please!) --Nickolay 06:19, 26 September 2006 (PDT)

Doesn't anyone use Help?

I think at least linking to information about the Help Viewer and creating a Help Content Pack ought to be included. I'd say "Include a section about Help Files and explaining how to use the extension" but seeing how it's been ignored so long leads me to conclude that most people think it's not too important.

But short or long, this information should be provided to new extension developers (such as myself). -- Rsperberg 10:31, 15 November 2007 (PST)

Document Tags and Contributors

Last updated by: trevorh,