{"id":7158,"date":"2014-06-05T09:00:21","date_gmt":"2014-06-05T16:00:21","guid":{"rendered":"http:\/\/blog.mozilla.org\/addons\/?p=7158"},"modified":"2020-02-11T15:51:25","modified_gmt":"2020-02-11T23:51:25","slug":"how-to-develop-firefox-extension","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/addons\/2014\/06\/05\/how-to-develop-firefox-extension\/","title":{"rendered":"How to develop a Firefox extension"},"content":{"rendered":"<p><strong><span style=\"color: #ff0000;\">Update: <\/span>Firefox has used the WebExtensions API as its extension API since 2017. We encourage you to visit <a href=\"https:\/\/extensionworkshop.com\/?utm_source=blog.mozilla.org&amp;utm_medium=post&amp;utm_campaign=how-to-develop-a-firefox-extension\">Extension Workshop<\/a> to learn more about browser extensions and how you can build an extension for Firefox. You can find reference documentation for the WebExtensions API on <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Mozilla\/Add-ons\/WebExtensions\/?utm_source=blog.mozilla.org&amp;utm_medium=post&amp;utm_campaign=how-to-develop-a-firefox-extension\">MDN<\/a>. <\/strong><\/p>\n<p><strong>Please do not reference this article for extension development, as it is out-of-date. If you are the developer of a legacy add-on, please refer to <a href=\"https:\/\/extensionworkshop.com\/documentation\/develop\/porting-a-legacy-firefox-extension\/?utm_source=blog.mozilla.org&amp;utm_medium=post&amp;utm_campaign=how-to-develop-a-firefox-extension\">this page<\/a> for resources to help you migrate to the current API.<\/strong><\/p>\n<hr \/>\n<p>It&#8217;s been a while since we published a guide on extension development in this blog, and we recently discovered that many of you are hitting a very old blog post about it. There&#8217;s plenty of documentation out there, but it can be hard to find, so here&#8217;s an overview of what you need to know about extension development.<\/p>\n<p>As with everything Mozilla, the first place you should look for developer documentation is the Mozilla Developer Network. There&#8217;s an <a href=\"https:\/\/developer.mozilla.org\/Add-ons\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>add-ons section<\/strong><\/a> there where you will find everything you need to know about how to develop Firefox extensions, as well as other add-on types.<\/p>\n<p>There are a couple different ways to go about creating an extension for Firefox, so I covered each in the sections below.<\/p>\n<h3>Add-ons SDK extensions<\/h3>\n<p>The <strong><a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\/SDK\" target=\"_blank\" rel=\"noopener noreferrer\">Add-ons SDK<\/a><\/strong> is a set of simple APIs you can use to quickly build good Firefox extensions. It&#8217;s what we recommend for new developers. It should be easy to work with, especially if you&#8217;re familiar with Google Chrome extensions or userscripts. It abstracts away most of the XUL \/ XPCOM infractrusture in Firefox, giving you a more familiar HTML and JS environment to work with.<\/p>\n<p>The current approach to building an SDK extension is to download and set up the SDK, code locally,\u00a0 then package your extension (an XPI file) using the cfx tool included with the SDK. The SDK team is working on making this process much easier by integrating it into Firefox developer tools. Soon you&#8217;ll be able to build your extensions very quickly, right from Firefox.<\/p>\n<p>You can learn more about the SDK and get help here:<\/p>\n<ul>\n<li><a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\/SDK\" target=\"_blank\" rel=\"noopener noreferrer\">Documentation on MDN.<\/a><\/li>\n<li><a href=\"https:\/\/blog.mozilla.org\/addons\/category\/sdk\/\" target=\"_blank\" rel=\"noopener noreferrer\">Articles in this blog.<\/a><\/li>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/tagged\/firefox-addon-sdk\" target=\"_blank\" rel=\"noopener noreferrer\">Stack Overflow.<\/a><\/li>\n<li><a href=\"https:\/\/forums.mozilla.org\/addons\/viewforum.php?f=27\" target=\"_blank\" rel=\"noopener noreferrer\">Add-ons forum.<\/a><\/li>\n<li>#jetpack channel on <a href=\"https:\/\/wiki.mozilla.org\/IRC\" target=\"_blank\" rel=\"noopener noreferrer\">Mozilla IRC.<\/a><\/li>\n<\/ul>\n<h3>Bootstrapped extensions<\/h3>\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\/Bootstrapped_extensions\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>Bootstrapped extensions<\/strong><\/a> don&#8217;t require a restart to be installed, like SDK extensions, but they don&#8217;t have the easy access to SDK APIs or sandboxing. You&#8217;re basically doing everything manually, like <a href=\"http:\/\/www.oxymoronical.com\/blog\/2011\/01\/Playing-with-windows-in-restartless-bootstrapped-extensions\" target=\"_blank\" rel=\"noopener noreferrer\">tracking windows to add or remove your UI<\/a>. However, there are various great tools available to you via <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Mozilla\/JavaScript_code_modules\" target=\"_blank\" rel=\"noopener noreferrer\">existing JavaScript Modules<\/a>, like <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Mozilla\/JavaScript_code_modules\/CustomizableUI.jsm\" target=\"_blank\" rel=\"noopener noreferrer\">CustomizableUI.jsm<\/a> for toolbar UI and <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Mozilla\/JavaScript_code_modules\/Services.jsm\" target=\"_blank\" rel=\"noopener noreferrer\">Services.jsm<\/a> for frequently used Firefox components.<\/p>\n<p>Compared to the old way of making extensions (see <em>Overlay extensions<\/em> below), the only notable loss are overlays. Bootstrapped extensions have the bootstrap.js file instead, which is what serves as the starting point for your code. Otherwise, everything should be familiar to you: <a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\/Install_Manifests\" target=\"_blank\" rel=\"noopener noreferrer\">install.rdf<\/a>, <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Chrome_Registration\" target=\"_blank\" rel=\"noopener noreferrer\">chrome.manifest<\/a> and code files, all packed in a ZIP file with a <em>.xpi<\/em> extension.<\/p>\n<p>Other than <strong><a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\/Bootstrapped_extensions\" target=\"_blank\" rel=\"noopener noreferrer\">Bootstrapped extensions<\/a><\/strong> on MDN and the pages they link to, all the available developer resources are the same for overlay extensions (see below).<\/p>\n<h3>Firefox for Android extensions<\/h3>\n<p><strong><a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\/Firefox_for_Android\" target=\"_blank\" rel=\"noopener noreferrer\">Extensions in Firefox for Android<\/a><\/strong> are slightly different. Since the UI is native instead of XUL, the way extensions can modify it is different and a bit more limited. This also means overlay extensions are not supported, so your options are the <a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\/SDK\/Tutorials\/Mobile_development\" target=\"_blank\" rel=\"noopener noreferrer\">SDK<\/a> and bootstrapped extensions.<\/p>\n<p>Since mobile applications have very limited screen real estate, browsers need to maximize the content area, meaning extensions can&#8217;t add buttons or toolbars to the browser. However, the Firefox for Android team recently developed the <a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\/Firefox_for_Android\/Firefox_Hub_Walkthrough\" target=\"_blank\" rel=\"noopener noreferrer\">Firefox Hub API<\/a> that lets extensions add their content to the home page. This is a smart place to put your extension UI if you need it.<\/p>\n<p>You can learn more about Firefox for Android extensions and get help here:<\/p>\n<ul>\n<li><a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\/Firefox_for_Android\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>Documentation on MDN.<\/strong><\/a><\/li>\n<li><a href=\"https:\/\/forums.mozilla.org\/addons\/viewforum.php?f=7\" target=\"_blank\" rel=\"noopener noreferrer\">Add-ons forum.<\/a><\/li>\n<li>#extdev and #mobile channels on <a href=\"https:\/\/wiki.mozilla.org\/IRC\" target=\"_blank\" rel=\"noopener noreferrer\">Mozilla IRC<\/a>.<\/li>\n<\/ul>\n<h3>Overlay extensions<\/h3>\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\/Overlay_Extensions\" target=\"_blank\" rel=\"noopener noreferrer\">Overlay extensions<\/a> are the old way of making add-ons. It might still make sense for you to use this approach if you need to create a very complex overlay or have other specific needs. However, having to restart Firefox to install this kind of extension is annoying because it breaks the user&#8217;s workflow, so you should definitely consider using the SDK or bootstrapped extensions first.<\/p>\n<p>You can get help about extension development in general here:<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/developer.mozilla.org\/en-US\/Add-ons\" target=\"_blank\" rel=\"noopener noreferrer\">Documentation on MDN.<\/a><\/strong><\/li>\n<li><a href=\"https:\/\/blog.mozilla.org\/addons\/\" target=\"_blank\" rel=\"noopener noreferrer\">Articles in this blog.<\/a><\/li>\n<li><a href=\"https:\/\/forums.mozilla.org\/addons\/viewforum.php?f=7\" target=\"_blank\" rel=\"noopener noreferrer\">Add-ons forum.<\/a><\/li>\n<li>#extdev channel on <a href=\"https:\/\/wiki.mozilla.org\/IRC\" target=\"_blank\" rel=\"noopener noreferrer\">Mozilla IRC<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Update: Firefox has used the WebExtensions API as its extension API since 2017. We encourage you to visit Extension Workshop to learn more about browser extensions and how you can &hellip; <a class=\"go\" href=\"https:\/\/blog.mozilla.org\/addons\/2014\/06\/05\/how-to-develop-firefox-extension\/\">Read more<\/a><\/p>\n","protected":false},"author":173,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44,295,124,742],"tags":[7120,278873,278876,278874,278882],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to develop a Firefox extension - Mozilla Add-ons Community Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.mozilla.org\/addons\/2014\/06\/05\/how-to-develop-firefox-extension\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jorge Villalobos\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.mozilla.org\/addons\/2014\/06\/05\/how-to-develop-firefox-extension\/\",\"url\":\"https:\/\/blog.mozilla.org\/addons\/2014\/06\/05\/how-to-develop-firefox-extension\/\",\"name\":\"How to develop a Firefox extension - Mozilla Add-ons Community Blog\",\"isPartOf\":{\"@id\":\"https:\/\/blog.mozilla.org\/addons\/#website\"},\"datePublished\":\"2014-06-05T16:00:21+00:00\",\"dateModified\":\"2020-02-11T23:51:25+00:00\",\"author\":{\"@id\":\"https:\/\/blog.mozilla.org\/addons\/#\/schema\/person\/a098261b4b5510d408ff31f492606925\"},\"breadcrumb\":{\"@id\":\"https:\/\/blog.mozilla.org\/addons\/2014\/06\/05\/how-to-develop-firefox-extension\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.mozilla.org\/addons\/2014\/06\/05\/how-to-develop-firefox-extension\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.mozilla.org\/addons\/2014\/06\/05\/how-to-develop-firefox-extension\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blog.mozilla.org\/addons\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to develop a Firefox extension\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.mozilla.org\/addons\/#website\",\"url\":\"https:\/\/blog.mozilla.org\/addons\/\",\"name\":\"Mozilla Add-ons Community Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.mozilla.org\/addons\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/blog.mozilla.org\/addons\/#\/schema\/person\/a098261b4b5510d408ff31f492606925\",\"name\":\"Jorge Villalobos\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.mozilla.org\/addons\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6d1966118f16e4b99a6e3ad07883be33?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6d1966118f16e4b99a6e3ad07883be33?s=96&d=mm&r=g\",\"caption\":\"Jorge Villalobos\"},\"description\":\"Jorge is the Product Manager for addons.mozilla.org\",\"url\":\"https:\/\/blog.mozilla.org\/addons\/author\/jvillalobosmozilla-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to develop a Firefox extension - Mozilla Add-ons Community Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.mozilla.org\/addons\/2014\/06\/05\/how-to-develop-firefox-extension\/","twitter_misc":{"Written by":"Jorge Villalobos","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/blog.mozilla.org\/addons\/2014\/06\/05\/how-to-develop-firefox-extension\/","url":"https:\/\/blog.mozilla.org\/addons\/2014\/06\/05\/how-to-develop-firefox-extension\/","name":"How to develop a Firefox extension - Mozilla Add-ons Community Blog","isPartOf":{"@id":"https:\/\/blog.mozilla.org\/addons\/#website"},"datePublished":"2014-06-05T16:00:21+00:00","dateModified":"2020-02-11T23:51:25+00:00","author":{"@id":"https:\/\/blog.mozilla.org\/addons\/#\/schema\/person\/a098261b4b5510d408ff31f492606925"},"breadcrumb":{"@id":"https:\/\/blog.mozilla.org\/addons\/2014\/06\/05\/how-to-develop-firefox-extension\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.mozilla.org\/addons\/2014\/06\/05\/how-to-develop-firefox-extension\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/blog.mozilla.org\/addons\/2014\/06\/05\/how-to-develop-firefox-extension\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.mozilla.org\/addons\/"},{"@type":"ListItem","position":2,"name":"How to develop a Firefox extension"}]},{"@type":"WebSite","@id":"https:\/\/blog.mozilla.org\/addons\/#website","url":"https:\/\/blog.mozilla.org\/addons\/","name":"Mozilla Add-ons Community Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.mozilla.org\/addons\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.mozilla.org\/addons\/#\/schema\/person\/a098261b4b5510d408ff31f492606925","name":"Jorge Villalobos","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.mozilla.org\/addons\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6d1966118f16e4b99a6e3ad07883be33?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6d1966118f16e4b99a6e3ad07883be33?s=96&d=mm&r=g","caption":"Jorge Villalobos"},"description":"Jorge is the Product Manager for addons.mozilla.org","url":"https:\/\/blog.mozilla.org\/addons\/author\/jvillalobosmozilla-com\/"}]}},"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/posts\/7158"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/users\/173"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/comments?post=7158"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/posts\/7158\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/media?parent=7158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/categories?post=7158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/addons\/wp-json\/wp\/v2\/tags?post=7158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}