XPCOM – It’s a place most XUL application and extension developers would rather avoid. There are times when XPCOM components are needed and developers have to bite-the-bullet. A few examples are commandline handlers, autocomplete implementations and the new custom query processors for XUL templates. If you’re lucky, you can use JavaScript to implement the XPCOM component.
Another very common use case in extensions is sharing data across browser windows. Technically, a JavaScript XPCOM component is the right way to go. But yeah, it’s XPCOM.
Well, Firefox 3 (Gecko 1.9) offers a new, simple, non-XPCOM method of sharing data: JavaScript Code Modules. Of course, you can use JS modules for lots of other purposes too. Check it out using a Firefox 3 beta or a nightly XUL Runner.
XPCOMutils.jsm probably deserves a shoutout here too… If you’re implementing a XPCOM component in JS, it really reduces the amount of boilerplate code you need to put in your component. [Such code can also be leak-prone in tricky ways.]
Here’s a patch from a few months ago showing how it works:
https://bugzilla.mozilla.org/attachment.cgi?id=269435&action=diff
Too bad that bug 406538 prevents this feature from being really useful. At least we can now use modules from chrome:// if they are not inside a JAR file – still, this is suboptimal for extensions.