Skip to content

Lesson 1 of 9 · 24m

Manifest V3 and the Extension Execution Model

The manifest is not metadata — it is the security boundary and the deployment contract. Learn what each execution context can and cannot do.

The first mistake teams make with browser extensions is treating the manifest like a package.json with a funny name. It is closer to a security policy: it tells the browser which code exists, where it may run, which capabilities it may touch, and which pages it may observe. Reviewers read it before they read your pitch deck, and so should attackers.

Start with the smallest truthful manifest

{
  "manifest_version": 3,
  "name": "Link Sanity Checker",
  "version": "1.4.0",
  "description": "Checks outbound links before a user opens them.",
  "action": {
    "default_popup": "popup.html",
    "default_title": "Check links on this page"
  },
  "background": {
    "service_worker": "background.js",
    "type": "module"
  },
  "permissions": ["storage", "activeTab", "scripting"],
  "host_permissions": ["https://*.github.com/*"],
  "icons": {
    "16": "icons/16.png",
    "48": "icons/48.png",
    "128": "icons/128.png"
  }
}

Every key here is a promise. permissions are extension APIs; host_permissions are site access. They are not interchangeable, and copying both from a tutorial is how an extension ends up asking to read every website when it only needed the active tab after a click.

Extensions are several programs in a trench coat

A single extension usually has four separate JavaScript contexts:

popup/options page ── extension origin, full extension APIs, lifetime of the window
background worker ── extension origin, no DOM, event-driven and frequently terminated
content script   ── web page origin, isolated JavaScript world, limited extension APIs
injected script  ── page main world, page JavaScript context, almost no extension APIs

They do not share globals. They communicate through explicit message channels or storage. When a bug report says "the variable is undefined," the first question is which process that variable lives in.

Declare capabilities by need, not convenience

action makes the toolbar button real. background registers the service worker. web_accessible_resources exposes files to pages, so use narrow matches instead of <all_urls>. Commands belong in commands, not in a popup-only keyboard listener. If a feature can be implemented without a manifest key, omit the key.

Field notes

  • background.type: "module" enables real ES module imports; without it, import statements fail in the worker.
  • A content script cannot call most extension APIs, even though it is "part of the extension."
  • The extension origin is chrome-extension://<id> (or the browser equivalent), not your website origin.
  • MV3 disallows remotely hosted executable code; shipping a loader that downloads JavaScript is both insecure and review-bait.

Was this lesson helpful?

Sign in to rate