Browser Plugins vs Extensions – the difference

August 10, 2010 16 Comments by Richard

Overloaded terms

One of the least understood concepts in the Browser Plugin world is — browser plugins.  What they are, and even more: what they are not.  Probably at least once a week I answer a question somewhere on a forum or on the comments on this blog and say “You can’t do that with a plugin; you need an extension”.

Many people confuse plugins and extensions in the browser world. They sound like they should be the same thing, but in fact they are very different.

What you can do with a plugin

A plugin is, quite simply, a third party library that “plugs in” to the browser that can be embedded inside a web page using an <embed> tag or a <object> tag.  Many of them then draw pretty pictures or animations, though that’s not required.  Many allow you to talk to them through javascript, though that’s not required.  In short, a plugin affects only a specific page in which it is placed.

Examples of common plugins include:

  • Macromedia Flash
  • Microsoft Silverlight
  • Apple Quicktime
  • Adobe Reader (at least this includes a plugin in addition to the rest of the application)

Some plugins respond to a mime type and can run in place of the page, such as Adobe Reader, which allows you to view PDF files in your web browser.  Again, however, it affects only that page, and no others.  In Firefox, Chrome, Opera, and Safari, these plugins are usually called “NPAPI plugins”, since they are written using the NPAPI.  In Safari, you could also use a Webkit Plugin.  In Internet Explorer you would do this with an ActiveX Control.

What a plugin cannot do

Plugins have to either handle a mime type or be embedded into a web page.  They don’t get put there automatically. They don’t create toolbars.  They don’t affect browser menus.  They don’t know about tabs, or even about other pages in the same browser process.  They don’t make coffee, tea, or hot chocolate, though they could be written to control an external appliance to do so if you really wanted.  They don’t automatically process the content of every web page loaded.

“But wait!” I hear you all cry.  “We have seen these magical things done! (well, except the hot chocolate machine)”

“Yes,” I reply.  “Those are extensions.”

Extensions

Extensions, or “add-ons”, can often do these magical things.  They can add onto the browser UI, process pages that the browser loads.  They do all sorts of things.  However, they are not the same thing as plugins; they affect the web browser itself, not really the page.  They may affect a page as well, of course.  In fact, you can even put a plugin inside an extension, at least in Firefox.  However, if you write an extension for Firefox, you’ll probably have to write it again for Chrome, Safari, and IE… one for each.  Perhaps there is a framework out there for writing portable extensions, though.  It’s not really my area of expertise, so I don’t know.

Examples of extensions / add-ons:

And many, many, many more.  Extensions can be written in different languages depending on the browser.  In Firefox you can write them in C++ or javascript, and on Internet Explorer you write them as special ActiveX controls called Browser Helper Objects, or BHOs.

An extension could contain a plugin, but a plugin can’t contain an extension

One very common way to install a plugin in Firefox is to use a .xpi file.  This is an extension.  It may have a NPAPI plugin inside of it, but it is still an extension.  It will not work on other web browsers, even though your NPAPI plugin may work perfectly fine on Chrome and Safari if installed in another way.

Conversely, a plugin by nature does not include an extension.

FireBreath

Nearly a year ago now I began a project called FireBreath, which is a cross-platform browser plugin architecture.  FireBreath is, frankly, awesome. You can literally get a plugin up and going in under 10 minutes if you already have everything installed.  That means you can spend your time doing other more important things, like actually developing your functionality, rather than spending all your time figuring out how to deal with the plugin APIs.

That said, FireBreath is a cross-platform browser PLUGIN framework.  It does not create extensions.  It will never be able to create extensions.  If you need an extension, you need something else.

When not to use a plugin

Finally, and this is a topic that people seem to think is a little strange coming from me, there are many cases when it is not a good idea to use a browser plugin.  In fact, a good rule of thumb is that if you can do what you need to do without one, don’t use one.

Why?

  • There are no really good ways to install browser plugins that will work 100% of the time
    • XPI install only works on one profile in firefox
    • CAB install only works in Internet Explorer and is sometimes a little unreliable
    • ClickOnce works only in Windows and only if .Net is installed
    • Java installers only work reliably and consistently on Mac OS
    • MSI or EXE installers while being the best method IMHO require a little more work on the part of the user, and the average user is… less savvy than you are, shall we say.
  • Plugins have to take into account a large range of hardware types
    • If you use graphics libraries such as OpenGL or DirectX keep in mind that every graphics card works a little differently with these technologies.  You will run into weird cases where your plugin doesn’t work on someone’s computer.  If your luck is like mine, that computer will belong to an executive at a fortune 500 company (yes, that happened to me.  no, it wasn’t fun)
  • Plugins don’t work until they have been installed
    • This is a major limiting factor to uptake of your site.  Many users don’t want to install yet another plugin on their machine, and many get lost in the incredibly complicated task of downloading and running the installer.

Moving on

If all of those things haven’t convinced you that what you want isn’t actually a browser plugin — great!  That’s why I’m still posting about this stuff.  Despite all the reasons not to use a plugin, there are also a lot of cases where it’s a good idea. Browesr plugin development can be a lot of fun!  Good luck!

  • http://www.facebook.com/smithkl42 Ken Smith

    Thanks. The topic was more confusing to me than it should have been. Great explanation — cleared up a lot for me.

  • Pingback: 插件和扩展 区别 | Geeklu.com

  • http://www.nursingideas.ca rdjfraser

    Agreed, extensions are great tools that I often recommend, but apparently have occasionally mislabeled them by calling them plug-ins. Now that I know the difference, I won’t accidently unwittingly confuse anyone else.

  • http://www.satya-weblog.com Satya Prakash

    Thanks for details.

  • Navaid Alam

    Good work clearing up the confusion.

    I am wondering on how a plug-in should be distributed.

    This is for an application at my company. The plug-in is a reasonably complex one (an ActiveX with a lot of help files and localized resource files and helper applications) installed in a separate directory of its own with a Firefox shim plug-in. We previously had an EXE installer packaged inside an XPI with a javascript file that would launch the exe. That doesnt seem to work now (actually for quite some time now). FYI – We also package the same EXE installer inside a CAB file for IE.

    We are now planning on restructuring the installer, so I am looking for some ideas. The idea is to provide a smooth installation experience.

  • http://colonelpanic.net taxilian

    There is a lot of discussion around this topic; The options are to distribute it in an .xpi file just as a .dll, which only works on firefox, to distribute it using a .cab file which can contain a .exe or .msi (preferred) but only works on IE (but will at least install for everything), or to use a downloadable installer.

    I recommend to FireBreath (http://www.firebreath.org) users to use an MSI (which is generated automatically using WiX for FireBreath plugins). If you use an MSI and just have the user download it, you have the same user experience on all platforms. The MSI should never let the dll self-reg because that loses the advantages of an MSI installer; instead, use the heat.exe WiX tool to generate the XML for the registry code for the plugin. This will save you a lot of possible problems in the long run over a .exe installer.

    The long and short of it is that there aren’t really any good options. If you use .msi, Google Omaha is one option that works better than many for keeping it updated. The most foolproof in my experience (having tried literally all possible options listed) is to have the user download a .msi and run it.

  • OvidiuC

    Great info! Thank you!!!

  • Magicsupery

    Awsome ! 

  • ab268

    as you said if we install a plugin using a .xpi it is actually an extension. I have a simple NPAPI plugin dll ready and want to install it on firefox 4 as a ‘plugin’. How should i go through it?

  • http://colonelpanic.net taxilian

    Currently the best places to find instructions for that is probably here: https://developer.mozilla.org/en/Gecko_Plugin_API_Reference/Plug-in_Development_Overview

    The answer to your question depends on your platform, which you have neglected to specify. That document should have instructions for you, though.

  • ab268

    Oh sorry
    I need to install it on Firefox 4 on Windows 7.
    The source code consists only of ns* functions. Does that make it an extension instead of a plugin? I also tried appending few np* functions like NP_GetEntryPoints, NP_Initialize and NP_GetMIMEDescription.
    But it is still recognized as an extension instead. So, according to this article, i presume i should use a different way to install it instead of using a .xpi .
    Can you help me in this regard?

    Thank You.

  • Koukaied

    I read this page about Plugins and Extensions,I saw “They don’t make coffee, tea, or hot chocolate, though they could be written to control an external appliance to do so if you really wanted.” Is it mean that Plugins can’t  control serial ports .

    I want user can control the com port via web, it seem ActiveX in IE can done, however,customer use firefox in ubuntu, it’s any difference develop method between WinXP and ubuntu OS?

  • Diegomussio

    Gvoice is a plugin not an extension!

  • http://colonelpanic.net taxilian

    when I said a plugin “could be writen to control an external appliance” … what part of that made you think you couldn’t control a COM port? It’s c++; of course you can.

  • http://colonelpanic.net taxilian

    gvoice is neither plugin nor extension; it’s not even a web technology. The interface is written in HTML/javascript.

  • Anupam

    thanks for the clarification…