views:

198

answers:

3

I've encountered posts which have stated, "I'd love to use Extension A but it doesn't work with Extension B". Is this something that I need to be concerned about when building a Firefox extension?

What are some of the common reasons for extensions to conflict with one another? What are the best practices to ensure that my extension plays nicely with all the other extensions?

+2  A: 

Not sure (resource contention is the obvious place to look) but you may have better luck posting to mozilla.dev.extensions

Jason S
A: 

Please post back if you find an answer! Thanks!

dmityugov
+2  A: 

The most common reason for extension conflicts is the use of common names in a shared namespace. For example, if two extensions define a global variable named "log" in a browser.xul overlay, only one of them will function as expected, since the other's "log" will be overwritten.

The common solution is learning which of your IDs will be dumped into a shared space and prefixing those with your own unique prefix.

For JavaScript code you could (and it's a good idea anyway) put your code into an object:

var myExtension = {
  onLoad: function() { ... },
  ...
}

instead of

function onLoad() {
}

Here is a pretty good write-up on the topic: http://blog.userstyles.org/2007/02/06/avoiding-extension-conflicts/.

Other conflicts are rare and have to be debugged on a case-by-case basis. For example there used to be a bug in Mozilla that caused event listeners on a node to be lost when the node was moved around the DOM. This caused multiple conflicts for the Menu Editor extension that allowed the user to rearrange menu items.

Nickolay