WebExtensions is a browser extension technology supported by most popular browsers. Using WebExtensions, you can create extensions that can slightly change the browser user interface, modify the contents of web pages, and change the network requests of the browser. WebExtensions are created using technologies such as HTML , CSS , JavaScript and JSON .
Content
Extension Structure
The WebExtensions extension is a zip archive with an almost arbitrary internal structure of nested directories and files. One of the few requirements in terms of structure is the presence of manifest.json, a JSON file that establishes a protocol for interaction between the browser, extension and browser user. What the manifest might contain:
- General information about the extension: name, version, short and full description.
- The list of permissions that the extension needs for its work and which the browser user either issues or rejects when installing the extension.
- Details of interaction with the browser: so-called. background pages and background JavaScript scripts that will be loaded into the browser at startup; content scripts - JavaScript scripts that will be loaded onto web pages that meet the specified conditions; Browser user interface elements - settings pages, icons in the toolbar, address bar, etc.
Architecture Features
Each background extension page, settings page or drop-down menu page is executed in a separate process with its own context. Interaction between separate scenarios of the same extension, between different extensions as well as the extension and the browser is carried out using a named message system. Most requests from the extension to the browser that can cause a delay (for example, reading and writing various data) are implemented using asynchronous APIs .
Multiple Browser Support
As of November 2017, extensions created using WebExtension are supported by all major browsers:
- Google Chrome and browsers based on the Chromium project: Opera, UCBrowser, Yandex.Browser, etc.
- Firefox - starting with version 45
- Microsoft edge
Internationalization Support
The WebExtensions extension can support many languages ββwith the built-in JavaScript library i18n.js. Files corresponding to different locales have a JSON format . Using special syntax, some fragments of the manifest.json file (for example, the name and description of the extension) can be automatically associated with strings from the corresponding locales, but the developer of the extension is mainly responsible for binding various elements of the extension user interface to localized strings.
Analogs
Analogs of WebExtensions technology is XUL , which was used in Mozilla Firefox prior to version 57, and Apple's proprietary technology, which is used to create extensions in the Safari browser.
Criticism
WebExtensions technology was developed as cross-browser, but in practice the level of support for different APIs varies from browser to browser. Depending on what features the extension implements, it may turn out that you need to create different archives to publish the extension in the directories of different browsers. Browser developers are trying to solve the problem of incompatibility with the help of migration guides, which only complicates the development of extensions.
In addition, browser developers criticize the extremely weak capabilities of WebExtensions compared to XUL - for example, WebExtensions does not allow creating independent panels from visited resources, forcing developers to intrude directly into the code of viewed pages or be limited by the poor features of the extension icon. A vivid example of the extension that prevented it from switching to WebExtensions is a widget that displays the latest news from RSS feeds in a creeping line.
Extension Examples
Examples of browser extensions created using WebExtensions technology and working in three or more browsers:
Links
- https://developer.chrome.com/extensions description extension API for Google Chrome browser
- https://dev.opera.com/extensions/ extension documentation on Opera Software
- https://developer.mozilla.org/en/Add-ons/WebExtensions description of WebExtensions on the Mozilla Developer Network website
- https://docs.microsoft.com/en-us/microsoft-edge/extensions description of WebExtensions for Microsoft Edge
- https://browserext.imtqy.com/browserext/ Browser Extensions, W3C Draft Community Group Report