Firefox Extension Template

By  on  

Creating a Firefox extension can be difficult if you don't know the files involved and how to structure your extension folder. Fear not -- I have created a very basic Firefox extension template file/folder structure for you to get your first plugin going.

File & Folder Structure

  • MyExtension/
    • chrome/
      • content/ - contains the extensions XUL and JavaScript files.
        • myExtension.xul - The XML that creates the layout of the extension.
        • options.xul - The XML that creates proviedes extension options. Empty for this template.
        • myExtension.js - The JavaScript that manages the action of each extension object.
      • locale/ - contains language files. None included in this template. Assume English.
      • skin/ - contains images and CSS to control extension object layout.
        • myExtension.css - a CSS file controling presentation, just like a website.
        • logo.png - a sample image. All images go in this folder as well.
    • chrome.manifest - maps out the file/structure layout of the extension for Firefox.
    • install.rdf - provides information about the extension.
    • update.rdf - gets pinged to check for extension updates.

Note that this structure isn't required but is a very commonly used structure. Also, make sure to check out my David Walsh Blog Toolbar post to see an example of my file contents.

Stay tuned for my post on creating the XPI file that packages the extension!

Recent Features

  • By
    fetch API

    One of the worst kept secrets about AJAX on the web is that the underlying API for it, XMLHttpRequest, wasn't really made for what we've been using it for.  We've done well to create elegant APIs around XHR but we know we can do better.  Our effort to...

  • By
    Create a Sheen Logo Effect with CSS

    I was inspired when I first saw Addy Osmani's original ShineTime blog post.  The hover sheen effect is simple but awesome.  When I started my blog redesign, I really wanted to use a sheen effect with my logo.  Using two HTML elements and...

Incredible Demos

  • By
    Submit Button Enabling

    "Enabling" you ask? Yes. We all know how to disable the submit upon form submission and the reasons for doing so, but what about re-enabling the submit button after an allotted amount of time. After all, what if the user presses the "stop"...

  • By
    Parallax Sound Waves Animating on Scroll

    Scrolling animations are fun. They are fun to create and fun to use. If you are tired of bootstrapping you might find playing with scrolling animations as a nice juicy refreshment in your dry front-end development career. Let's have a look how to create animating...

Discussion

  1. I guess both of us think alike :) http://github.com/cheeaun/example-fx

  2. @Lim Chee Aun: As always! :) This setup is pretty common.

  3. u mis-typed the word “chrome”…

  4. @Foobar: Updated.

  5. Thanks a bunch David, I’ve always wanted to try my hand at creating my own Firefox tool bar but never really knew how to start. Thanks for the jump start. ;)

  6. You can use an Extension Wizard for that purpose.

  7. Scott Morris

    I have been tasked to create an add on and through all the searching and examples yours was the best. Thank you.

  8. andrew

    I have defind a new action that to call other program In my myExtension.js ,
    Am i input the program with myExtension.js in content too ?

  9. I always to the star to make my Firefox toolbar, but knew how to really wanted to try my hand but never.
    ——————————–
    ruthallen

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!