Browser-specific manifest fields
Avoid maintaining separate manifest files for every browser.
Extension.js lets you define browser-specific values inline with prefixes, then emits only the fields that match the active target at compile time.
Why this matters
Browsers still differ in key manifest areas, like background configuration and vendor metadata. Prefixed fields let you keep one source manifest.json while producing browser-correct output for Chromium and Firefox families.
How it works
Extension.js scans manifest keys and resolves prefixed entries for the selected browser:
- Chromium family targets (
chrome,edge,chromium-based) resolve:chromium:,chrome:,edge: - Gecko family targets (
firefox,gecko-based) resolve:firefox:,gecko:
When a prefixed key matches the active target, Extension.js rewrites it to the unprefixed key in the emitted manifest.
For Chromium-based browsers (Chrome, Edge, ...)
For Firefox
You can also target vendor-specific variants inside the same browser family:
This makes service_worker available only for Chromium-family outputs while keeping background.scripts for Firefox outputs.
Supported prefix map:
This works for any manifest field at any level, including permissions, content_scripts, and background.
Best practices
- Keep shared defaults unprefixed: Put common fields in regular manifest keys, then prefix only browser-specific differences.
- Prefix only when behavior diverges: Use browser prefixes when runtime requirements differ.
- Build per target in CI: Generate and verify each browser output (
dist/<browser>) to catch compatibility regressions early. - Validate with MDN: Use MDN Web Docs to confirm support before adding browser-only settings.
Next steps
- Learn more about the Browsers Available.
- Learn more about Cross-Browser Compatibility.
