Why you should make your next add-on restartless + more

Jorge Villalobos

5

Wladimir Palant, lead developer of the very popular Adblock Plus add-on has a couple of interesting posts up in his blog.

In his first article, Why you should make your next add-on restartless, he weighs the pros and cons of creating a restartless (non-SDK) add-on.

For me, the advantages clearly outweigh the disadvantages. If you already have a classic extension then you may wait with converting it until you actually have time for that. But if you are planning a new extension then you certainly should make it restartless.

In Modularization in a restartless extension he goes more in depth and shows you how to implement a module loader.

A simple restartless extension can probably keep all its code in the bootstrap.js file. However, it gets crowded there very soon. Plus there is some code that is really only boilerplate and should probably kept separate from your actual code.

I recommend you give them both a read. Boostrapped extensions are still challenging to create, specially due to the limited documentation we have on them. However, once you get the basics going, the payoff is really big.

5 responses

  1. tom jones wrote on :

    are you ever planning to fix XBL to work in bootstrapped extensions?

    because until that happens, lots of addons can’t get the restartless goodness..

  2. a wrote on :

    It’s not an option for my extension until NPAPI plugins can be included in restartless extensions.

    1. Jorge Villalobos wrote on ::

      What do you use NPAPI for? Have you considered using JS-ctypes instead?

      1. a wrote on :

        Last I checked there wasn’t a way of passing a JS function in to a C function for use as a callback and there was no reasonable way to monitor a file descriptor.

        Frankly, even if there were I’d be unlikely to use ctypes as the plugin needs to be maintained for other browsers in any case.

        As navigator.plugins.refresh() can already deal with plugins being added and removed and other browsers already support this functionality I’m surprised that this isn’t already part of Firefox.

  3. Raven wrote on :

    any plans to un-uglify / standardize the bootstrap.js? It would make for faster reviews if it was a jsm module, wrapping the code into an object with a few simple methods…

    In my mind putting your own code in there should be strongly discouraged…
    Raven