background preloader

Restartless tutorial

Facebook Twitter

Restartless Firefox Add-ons, Part 8: Require, CommonJS, and Jetpack - Erik Vold's Blog. Jetpack is the future.

Restartless Firefox Add-ons, Part 8: Require, CommonJS, and Jetpack - Erik Vold's Blog

Give the old school add-ons up, it's over. Because sooner or later everything will be possible with some CommonJS style module, which would mean you'd be a fool to ignore these modules. At the moment, I see normal restartless add-ons as those that write their own bootstrap.js file, which is a method I've been trying to help people learn to do with this series, because I felt it would be a stepping stone to converting existing old school add-ons to Jetpacks which I needed, and that other developers might need as well. Now, I can't explain why very well, but I feel that there is a freedom writing the bootstrap yourself which is very nice, and although it requires me to think about how to cleanup my code a lot more , that's something I needed.

There are serious drawbacks to building Jetpacks I think as well. With that you can start writing CommonJS modules which can be used by Jetpacks and even NodeJS and the like, as well as for your lean mean restartless add-ons. Restartless Firefox Add-ons, Part 5: Logging - Erik Vold's Blog. This is a simple one for most of you, but I found someone asking the question "How do I dump messages from bootstrap.js" on stackovercrap so I thought it would make a good topic to quickly blog about.

Restartless Firefox Add-ons, Part 5: Logging - Erik Vold's Blog

First of all what I'm about to describe is exactly how one would log messages and report errors from a JavaScript code module , so if you already know how to do this, then stop reading and bounce. If you are lost without window.dump or don't know what that is, then give this page a quick read. There is a note that says: "dump is commonly used to debug JavaScript. Privileged code can also use Components.utils.reportError and nsIConsoleService to log messages to the Error Console. " Bingo! The window.dump page also mentioned Components.utils.reportError which can be used for logging error messages to the Error Console. Restartless Firefox Add-ons, Part 4: Localization (l10n) - Erik Vold's Blog. Alright, part four has been a long time coming, but I finally got around to typing out an localization include for restartless Firefox 4 addons which I'm ready to talk about.

Restartless Firefox Add-ons, Part 4: Localization (l10n) - Erik Vold's Blog

If you haven't read part 2 it's all about how to use includes, so read it first, if you don't know what a restartless addon is, then start with part 1 . To start off with I wrote this include for Restartless Restart , and I consider that to be my demo. Overview Alright, so you should know how to use includes in a restartless addon now, and I shouldn't have to explain why localizing your addon is important, and you have an example; here are some notes: To begin with you will need to copy this l10n.js file in to your addon, then include it at startup (in your addons bootstrap.js file) and create the all important underscore function (literally "_(aKey)"), like so: Setup Using _ _ takes 2 arguments aKey, and aLocale which is optional. aKey is the key for the text in your .properties file.

Conclusion. Restartless Firefox Add-ons, Part 3: Icons - Erik Vold's Blog. Restartless Firefox Add-ons, Part 2: Includes - Erik Vold's Blog. Today I'm going to write about including files into your bootstrap.js file's scope.

Restartless Firefox Add-ons, Part 2: Includes - Erik Vold's Blog

There are a few different types of files that you'll want to include, and I'm only going to talk about three of them today, importing javascript modules provided by Firefox or other extensions, and including (using loadSubScript) files packaged with your add-on, or any other. Importing Modules This is pretty simple, Components is available, so Components.utils.import is available.

So import javascript modules like so: Note: I highly recommend reviewing the Services.jsm module, it's a handy one. Restartless Firefox add-ons, part 1: Giving your add-on the bootstrap - Erik Vold's Blog. Intro Firefox 4 will introduce a new type of add-on to users, the restartless add-on !

Restartless Firefox add-ons, part 1: Giving your add-on the bootstrap - Erik Vold's Blog

It's true that there are many problems that need to be resolved before all add-ons can be made restartless , which should help illustrate why it has taken as long as it has for Mozilla to introduce the feature.