In some cases during the development of a cross-browser extension, certain manifest fields or API configurations are only relevant to specific browsers. With Extension.js, you can prefix the manifest field with the browser name to ensure that the field is only compiled for that browser.
This approach ensures that the service_worker
field is only applied when targeting Chromium-based browsers, while the scripts
field works exclusively for Firefox. Below is a list of supported prefixes and their corresponding target browsers:
Browser | Prefix | Target browser |
---|---|---|
Chromium | chromium: |
All Chromium-based browsers |
Chrome | chrome: |
Chrome browser |
Edge | edge: |
Edge browser |
Firefox | firefox: |
Firefox browser |
Gecko | gecko: |
All Gecko-based browsers |
Safari | Coming soon | Safari browser |
WebKit | Coming soon | All WebKit-based browsers |
Desktop | Coming soon | All desktop browsers |
Mobile | Coming soon | All mobile browsers |
This feature works for any manifest field at any level, including permissions
, content_scripts
, background
, and more.