Chrome Extensions Tutorial
Learn Chrome Extensions step by step: 36 lessons in 9 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Getting Started
- What Are Chrome Extensions? Learn what a Chrome extension is, what it can and cannot do, which browsers run it, and how this course teaches extensions on a site that cannot load them.
- The Anatomy of a Chrome Extension Meet every part of a Manifest V3 extension: manifest, service worker, popup, options page, content scripts and side panel, and see where each one runs.
- Your First Extension, Loaded in Chrome Create a Hello World Chrome extension with a manifest, popup and content script, load it with Load unpacked, and reload it after each change.
- Manifest V3 and Why It Exists Understand Manifest V3: service workers instead of background pages, no remote code, declarativeNetRequest, host permissions, and how to migrate old extensions.
Manifest V3 and Structure
- manifest.json Basics Learn the required and common keys in a Manifest V3 manifest.json: name, version, description, icons, action, background and permissions, with a live validator.
- Manifest Fields You Will Actually Use A tour of the manifest keys beyond the basics: commands, options_ui, web_accessible_resources, minimum_chrome_version, side_panel, omnibox and more, with examples.
- Folder Structure, Icons and Translations Organize an extension project, create correctly sized icons including SVG-to-PNG, and translate your extension with _locales, messages.json and chrome.i18n.
- Match Patterns: Choosing Where to Run Master match patterns for content_scripts and host_permissions: scheme, host, path, wildcards, all_urls, exclude_matches and common mistakes, with a live matcher.
Popup, Options and Content Scripts
- Building a Popup Build a toolbar popup for your Chrome extension. Configure action.default_popup, size the window, load scripts correctly, query the active tab and handle the popup lifetime.
- Popup UI Patterns and State Design better popups: small state machines, toggles and lists, loading and error states, keyboard access, dark mode with prefers-color-scheme, and clean separation of logic.
- The Options Page Add a settings page to your Chrome extension with options_ui, save preferences to chrome.storage.sync, validate input, reset defaults and react to changes in other parts.
- Content Scripts Basics Learn how content scripts work: declare them in the manifest, choose run_at, read and edit the page DOM, add CSS, watch for changes with MutationObserver and use allowed APIs.
- The Isolated World and the Page's World Understand why content scripts cannot see page variables, how the isolated world protects both sides, and how to reach page code with the MAIN world, window.postMessage and custom events.
- Injecting Scripts Programmatically Inject scripts and CSS on demand with chrome.scripting.executeScript and insertCSS, pass arguments, read results, use activeTab, and register dynamic content scripts.
Background Service Workers
- Service Worker Basics Learn the extension service worker: declare it in the manifest, register listeners at the top level, use chrome.runtime.onInstalled, avoid DOM and global state, and import modules.
- The Service Worker Lifecycle Understand when the extension service worker starts, how long it lives, what keeps it alive, why it stops, and how to design long tasks, retries and state restoration.
- Events, Alarms and the Badge Handle browser events with filters, schedule repeating work with chrome.alarms, update the toolbar badge, and use offscreen documents when a service worker needs a DOM.
- Context Menus, Shortcuts and Notifications Add right-click menu items with chrome.contextMenus, keyboard shortcuts with chrome.commands and desktop alerts with chrome.notifications, all handled by the service worker.
Messaging and Storage
- One-Time Messages with runtime.sendMessage Send one-time messages between the popup, content scripts and the service worker with chrome.runtime.sendMessage and tabs.sendMessage, reply asynchronously, and avoid the classic port-closed error.
- Long-Lived Connections with Ports Open long-lived channels between extension parts with runtime.connect and onConnect, stream many messages over one port, handle disconnects, and know when ports are better than one-time messages.
- The chrome.storage API Save extension data with chrome.storage.local, sync, session and managed, read and write with promises, set defaults, remove keys, and learn why storage beats localStorage and global variables in Manifest V3.
- Storage Patterns - onChanged, Quotas, Migrations React to storage changes with storage.onChanged, keep every extension page in sync, avoid read-modify-write races, check quotas and migrate stored data between versions of your extension.
Permissions and Security
- The Permissions Model - Ask for Less Understand permissions, host_permissions, optional permissions and activeTab in Manifest V3, request access at runtime with chrome.permissions, and follow the least-privilege rule that store reviewers expect.
- Content Security Policy for Extensions Learn the default Content Security Policy of Manifest V3 extensions, why inline scripts and eval are blocked, how to fix common violations, and how to loosen the policy only where it is safe.
- Secure Messaging and Untrusted Input Treat web pages as hostile, validate message senders and shapes, avoid innerHTML and XSS in content scripts, limit externally_connectable, and apply a practical security checklist to your extension.
- Least Privilege, Privacy and Data Handling Reduce what your Chrome extension can touch with narrow matches, activeTab and declarative alternatives, handle user data responsibly, and prepare the privacy disclosures the Web Store requires.
Testing and Debugging
- Debugging Every Extension Context Find and fix extension bugs by opening the right DevTools for the service worker, popup, options page and content scripts, read the errors page, trace messages and fix the most common MV3 problems.
- Unit Testing Extension Code with Mocks Write testable extension code by separating pure logic from chrome APIs, inject a fake chrome object, test storage and message handlers with Vitest or Jest, and run fast tests without a browser.
- End-to-End Testing in a Real Browser Run end-to-end tests that load your unpacked extension in Chromium with Playwright or Puppeteer, find the extension id, open the popup, test content scripts on a local page, and run them in CI.
Publishing
- Preparing Your Extension for the Chrome Web Store Get a Chrome extension ready to publish: a clean manifest, required icons and screenshots, a clear single purpose, a privacy policy, a production build and a zip package that passes review.
- Submitting to the Web Store and Passing Review Register a developer account, upload your extension package, fill in the listing and privacy tabs, choose visibility, understand the review process and fix the most common rejection reasons.
- Updates, Versioning, Localization and CI Ship extension updates safely with semantic versioning, staged rollout, onInstalled migrations, _locales translations and an automated build and publish pipeline using the Chrome Web Store API.
Projects and Practice
- Project: Page Notes Extension Build a complete Manifest V3 extension that saves a note for any web page, shows it in a popup, lists all notes on an options page and syncs across extension pages with chrome.storage.
- Project: Price Highlighter with a Content Script Build an extension whose content script finds prices in page text and wraps them in a highlight, with an on/off switch in the popup, settings in storage and safe DOM changes.
- Project: Tab Snoozer with Alarms and Notifications Build a tab snoozer that closes a tab and reopens it later using chrome.alarms, chrome.storage and a service worker that survives restarts, with a testable scheduling core and a store-ready checklist.
- Practice: Extension Challenges and Code Review Test your Chrome extension skills with hands-on challenges on messaging, storage, permissions and security, review a flawed extension for bugs, and plan three project ideas to build next.