LWN.net Logo

Jetpack: Firefox extensions as they should be

June 3, 2009

This article was contributed by Koen Vervloesem

One of the great strengths of Firefox is its extensions ecosystem. Over 12,000 enhancements for the browser are available, varying from additions of simple features to complete applications such as IRC or FTP clients. Many users just keep Firefox as their default browser because they can't live without specific extensions that don't exist in other browsers. This hackable nature of Firefox is something that Mark Surman of the Mozilla Foundation has emphasized countless times, for example in his keynote at FOSDEM 2009 a few months ago: only the ability to extend the web makes it truly the user's web.

Unfortunately, developing a Mozilla Firefox extension is far from easy. It requires a fair bit of knowledge of a strange mix of technologies: RDF (Resource Description Framework), XUL (XML User Interface Language), XPI (Cross-Platform Installer), XPConnect, XPCOM (Cross-Platform Component Object Model), DOM (Document Object Model), JavaScript and CSS (Cascading Style Sheets). Hence, the user willing to enhance his browser has to become well-versed in a long list of arcane languages.

To address this, the Mozilla Add-ons blog posed the question "How can we make the development of extensions easier?" and published an Extension Developer Survey. The top 5 requests were more concerned about the review queue, documentation, tutorials and writing and debugging tools, but several responses suggested some improvements to the add-on platform itself:

  1. not requiring browser restart for installation
  2. better debugging tools
  3. better packaging
  4. easier way to write extensions
  5. code generation/IDE

The Mozilla developers have clearly listened to these suggestions, as last week Mozilla Labs announced Jetpack, a new experimental extensions architecture which abstracts away much of the complexity of the current extensions system. The Jetpack API addresses the five issues mentioned above and at the same time lowers the bar for users by requiring only knowledge of HTML, CSS and JavaScript. This means that everyone with basic web development skills is able to extend their web browser using the same web technologies they already know. The choice for these web standards is also clever because it means that extension developers can re-use existing web development and debugging tools. For example, a Jetpack extension writer is able to use the Firebug extension (a popular extension for debugging, editing and monitoring CSS, HTML, DOM, and JavaScript) to develop his add-on.

Writing a Jetpack extension

To get started, users have to install the Jetpack Extension and restart Firefox. The browser then shows the about:jetpack page, which contains some Jetpacks (extensions created with the Jetpack API). Jetpack community lead Nick Nguyen writes on his blog how easy it was for him to develop a new Jetpack:

I was able to put together a Delicious Notifier Jetpack Feature in less than an hour using simple JQuery, CSS, and html. All I did was install the GMail Notifier widget and pasted it into Bespin, read the 20 lines of code that made it work, and started hacking away to get the information i wanted. Since I didn’t have to restart and could inspect and debug via Firebug, development was painless.

There are some demos one can use for inspiration, as Nguyen showed in his blog. The Jetpack Tutorial is also very helpful to start. Developing a Jetpack extension turns out to be surprisingly simple. It's an iterative process where the developer writes some code right in his browser, refreshes a web page to see the effect of his changes in the Jetpack extension code, then continues rewriting his code, and so on. One especially interesting feature is that Jetpack has automatically included jQuery by default. This popular JavaScript library exposes a lot of functionality, like DOM traversal and modification, events, CSS manipulation and Ajax. The tutorial shows how to write a script of only ten lines that removes embed elements from a page on-demand and at the end of the tutorial, the user learns how to write his own GMail notifier. Jetpack also has a Twitter library and will see more common web APIs in the future, including the ability to import external libraries.

At the moment, the API reference is woefully incomplete, but this should change as people start to experiment with Jetpack. Most of the interesting objects reside in the jetpack namespace. For example, the jetpack.notifications object can be used to display a notification message, and by using jetpack.tabs properties, the developer is able to manipulate the browser's tabs.

Even distributing a Jetpack extension is simple: just drop the code into a JavaScript file. Add a link element to a page:

    <link rel="jetpack" href="js-file">

Subsequently, a visitor to the page will see a notification bar with the option to install the Jetpack. It's also nice to see the developers have thought about security: the user sees the whole Jetpack extension source code before he installs it. In the future, the Jetpack system will work with a "social trust network" to help people make informed decisions about whether to install a Jetpack extension or not.

When using Firefox 3.0 or earlier, any logging messages or errors produced by Jetpacks reference the wrong line numbers, which makes debugging Jetpacks difficult. So anyone planning to experiment with Jetpack should consider using Firefox 3.5 Beta. Moreover, if the user doesn't have the latest version of Firebug installed, all logging messages appear in the JavaScript Error Console. For serious debugging, the Jetpack developers strongly suggest using Firebug 1.4 Alpha.

Conclusion

At the moment Jetpack is still an early prototype (that's why it's in Mozilla Labs), and it is not meant to replace the existing extension system. It is however well-suited for simple addititions to Firefox, analogous to the changes users can make to web pages with Greasemonkey. For this purpose, Jetpack clearly looks like the right choice: it not only makes developing extensions much simpler, but it creates new possibilities, such as installing an extension without the need to restart the browser.


(Log in to post comments)

Jetpack: Firefox extensions as they should be

Posted Jun 4, 2009 14:25 UTC (Thu) by tykepenguin (subscriber, #4346) [Link]

It might be just the new contributors, but there seems to be a growing trend of "he"s and "hims"s in the articles on lwn which I find rather jarring ... remember, not all Linux users or even developers are male :-)

Jetpack: Firefox extensions as they should be

Posted Jun 4, 2009 17:43 UTC (Thu) by Tet (subscriber, #5433) [Link]

Maybe so, but it's idiomatic English. I'd rather that than "she" and "her", which is far more jarring to my eyes. Of course, using a singular they would solve that problem, but it's use still isn't universally accepted.

Jetpack: Firefox extensions as they should be

Posted Jun 4, 2009 17:57 UTC (Thu) by RobSeace (subscriber, #4435) [Link]

Unfortunately, it's just down to limitations in the English language... We have no gender-neutral pronouns... The best we've come up with is singularizing "they"/"them"/"their", which tends to annoy grammar-nazis... (Though, I like it think it's the best way to go...)

But, many people were taught that "he"/"him"/"his" was perfectly acceptable and encouraged for gender-neutral use... So, trying to read any kind of bias or sexism into such use is really reaching, I think... It's just common usage, and not meant to truly restrict things to males only... Just as "mankind" includes women as well as men, so can a generic usage of "he" stand for a woman as well as a man...

Jetpack: Firefox extensions as they should be

Posted Jun 6, 2009 4:18 UTC (Sat) by dododge (subscriber, #2870) [Link]

The best we've come up with is singularizing "they"/"them"/"their",

Which is hardly a new development. The OED has numerous supporting quotations showing common use of singular "they" back to the 1500s and singular "their" to the 1300s. This goes back so far that the earliest examples are barely recognizable as English. The OED does note on one of the entries that the usage is "not favoured by grammarians".

Gender neutrality: Not that hard

Posted Jun 9, 2009 2:13 UTC (Tue) by kevinbsmith (guest, #4778) [Link]

I strongly prefer gender neutrality, and I think it is worth a little effort. I do understand that especially for non-native speakers, using he/him/his may seem very natural. However, we can fix the problem over time, if we choose to.

In this article, it would have been pretty easy to fix the remaining cases of inadvertent sexism, while remaining grammatically correct. I think some of these would be improvements even aside from the gender issues.

"the user willing to enhance his browser" -> "users willing to enhance their browsers"

"to develop his add-on" -> "to develop an add-on"

"the developer writes some code right in his browser, refreshes a web page to see the effect of his changes in the Jetpack extension code, then continues rewriting his code, and so on" -> "the developer writes some code right in a browser, refreshes a web page to see the effect of the changes in the Jetpack extension code, then continues rewriting the code, and so on"

"the user learns how to write his own GMail notifier" -> "the user learns how to write a GMail notifier"

"the user sees the whole Jetpack extension source code before he installs it" -> "the user sees the whole Jetpack extension source code before choosing to install it"

There may be documents where eliminating he/him/his would be awkward, but this doesn't seem to be one of them. Basically, I look at any inappropriate he/him/his as being a yellow flag that the sentence should be refactored.

By the way, I apologize for not having something to say about the contents of the article itself. I stopped using FireFox a while ago. I guess I'll just say that it seemed to cover the material pretty well.

You think we have problems?

Posted Jun 9, 2009 4:32 UTC (Tue) by quotemstr (subscriber, #45331) [Link]

Here's an excerpt from Mark Twain's "The Awful German Language"
I translate this from a conversation in one of the best of the German Sunday-school books:

"Gretchen.
Wilhelm, where is the turnip?
Wilhelm.
She has gone to the kitchen.
Gretchen.
Where is the accomplished and beautiful English maiden?
Wilhelm.
It has gone to the opera."

To continue with the German genders: a tree is male, its buds are female, its leaves are neuter; horses are sexless, dogs are male, cats are female -- tomcats included, of course; a person's mouth, neck, bosom, elbows, fingers, nails, feet, and body are of the male sex, and his head is male or neuter according to the word selected to signify it, and not according to the sex of the individual who wears it -- for in Germany all the women either male heads or sexless ones; a person's nose, lips, shoulders, breast, hands, and toes are of the female sex; and his hair, ears, eyes, chin, legs, knees, heart, and conscience haven't any sex at all. The inventor of the language probably got what he knew about a conscience from hearsay.

The confusion doesn't seem to have caused the Germans any great hardship. Gender neutrality in English is overblown at best: no reasonable person is going to suppose that female programmers don't exist merely because an article uses 'he' in an impersonal context; nor will someone who habitually thinks of male programmers suddenly revise his mental model because an article uses a plural.

It's useless at best to go around asking writers to contort perfectly good sentences on the account of the dubious idea that changing a pronoun will fix society. I imagine there are countless ways to address inequality that have the twin advantages of being effective and leaving our language intact.

You think we have problems?

Posted Jun 12, 2009 6:47 UTC (Fri) by kreutzm (guest, #4700) [Link]

You display the issue simpler than it is. This problem exists in German as well, for example in law you often write things like: "The actor/actress who uses his/her ..." (except for laws dealing with maternity). And we infrequently discuss simmilar issues like those in earlier comments (for example the German word for university student is "Student" but this is also the male form, so a gender neutral form "Studierender" is often used, although this is strictly speaking not the same).

And as a side note, not all genders are "random" in German. For example the neutral gender of maiden you used in your quote is actually based on a rule. In German words ending with "chen" are denoting small things of something usually "larger", e.g. Brot -> Brötchen (bread -> rolls). Those words are always neutral, independent of the gender of the originating word. The confusing issue here is that girls are small woman (the old, no longer used word in German was "maid") but boys are not called small man. Maybe the inventor of German language did not know if boys really where small man, while he was sure for woman :-))

Copyright © 2009, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds