|
| 1 | +--- |
| 2 | +display_name: Web extension/browser extension |
| 3 | +short_description: A browser extension is a way to add customization to a browser. |
| 4 | +topic: web-extension |
| 5 | +aliases: browser-extension, webextension |
| 6 | +related: chrome-extension, firefox-extension, safari-extension |
| 7 | +url: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions |
| 8 | +wikipedia_url: https://en.wikipedia.org/wiki/Browser_extension |
| 9 | +--- |
| 10 | +A **browser extension** or **web extension** (also written as **WebExtension**) is a way to customize various aspect of a browser's functionality: |
| 11 | +* user interface modifications |
| 12 | +* cookie management |
| 13 | +* ad blocking |
| 14 | +* custom scripting and styling of web pages |
| 15 | + |
| 16 | +Other than browser plugins, they are distributed as source code, while plugins are executable. |
| 17 | + |
| 18 | +While there is a [common standard](https://en.wikipedia.org/wiki/Manifest_file#WebExtension_manifest) (to which Mozilla switched in 2015), there are slight differences between the browser's implementations of said standard: |
| 19 | +* [Mozilla Firefox](https://github.com/topics/firefox-extension) (gecko engine) |
| 20 | + * gecko uses `browser` when referring to the browser object in scripts, but supports using `chrome` |
| 21 | + * supports non-persistent background scripts called "event-driven background scripts" |
| 22 | +* [Google Chrome](https://github.com/topics/firefox-extension) (webkit engine) |
| 23 | + * webkit uses `chrome` when referring to the browser object in scripts |
| 24 | + * instead of event-driven background scripts, Chrome has service workers |
| 25 | +* Apple's [Safari](https://github.com/topics/firefox-extension) (also webkit) |
| 26 | +* _Browser-specific settings can be applied to the `browser_specific_settings` key in the `manifest.json`_ |
| 27 | + |
| 28 | +The WebExtension manifest standard is currently in version 3 (called "Manifest V3"), but Firefox still supports version 2 (called "Manifest V2"). |
| 29 | +* Some key names changed (e.g. `browser_action` to `action`) |
| 30 | + |
| 31 | +An extension is roughly divided into parts, of which not all might be used: |
| 32 | +* **content scripts:** Scripts that manipulate the web page of the current tab |
| 33 | +* **background scripts:** Scripts that don't have access to the web page but can do other tasks, including displaying a popup when clicked on the extension icon |
| 34 | + |
0 commit comments