Skip to content

Keep your coding agent up to date with the latest web best practices

Release v0.0.171

github-actions[bot]a8374de7a9d5
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json
index f4d60ce..626108b 100644
--- a/.claude-plugin/marketplace.json
+++ b/.claude-plugin/marketplace.json
@@ -8,7 +8,7 @@
"name": "modern-web-guidance",
"source": "./",
"description": "Keep your coding agent up to date with the latest web best practices",
- "version": "0.0.170"
+ "version": "0.0.171"
}
]
}
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index 6e670a5..dffbda8 100644
--- a/.claude-plugin/plugin.json
+++ b/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "modern-web-guidance",
"description": "Keep your coding agent up to date with the latest web best practices",
- "version": "0.0.170",
+ "version": "0.0.171",
"author": {
"name": "Google Chrome"
}
diff --git a/.cursor-plugin/plugin.json b/.cursor-plugin/plugin.json
index 280649d..e31a646 100644
--- a/.cursor-plugin/plugin.json
+++ b/.cursor-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "modern-web-guidance",
"description": "Modern Web Guidance is an agent skill and CLI tool designed to help AI coding agents build web applications using modern, secure, and high-performance APIs rather than outdated workarounds. Supported by the Google Chrome team, it injects expert-curated web platform best practices directly into an agent's context window to prevent the generation of bloated, legacy code.",
- "version": "0.0.170",
+ "version": "0.0.171",
"author": {
"name": "Google Chrome"
}
diff --git a/README.md b/README.md
index aa0c211..0b205e3 100644
--- a/README.md
+++ b/README.md
@@ -4,9 +4,7 @@
# Modern Web Guidance
-Inject web platform expertise, best practices, and modern API patterns directly into your AI coding agents.
-
-**Modern Web Guidance** is an agent skill (aka `SKILL.md`) with a CLI that helps coding agents build better web applications using modern, high-performance, accessible, and secure APIs instead of legacy workarounds.
+Modern Web Guidance is a set of skills that embed web platform expertise, best practices, and browser compatibility data directly into your coding agents. It helps to steer your coding agents away from legacy patterns, and instead toward solutions that harness the power and capabilities of the modern web platform.
*Supported by the Google Chrome team, the Microsoft Edge team, and the web development community.*
@@ -21,7 +19,7 @@ Inject web platform expertise, best practices, and modern API patterns directly
npx modern-web-guidance@latest install
```
-This command runs an interactive wizard to place the SKILL.md appropriately. See [Alternative Installation Methods](#-alternative-installation-methods) below.
+This command runs an interactive wizard to install Modern Web Guidance. See [Alternative Installation Methods](#-alternative-installation-methods) below.
#### Try it out (without installing)
@@ -41,7 +39,7 @@ Even if a model knows an API exists, it often lacks the density of real-world, m
**Modern Web Guidance bridges this gap.** Our skill's CLI returns targeted, expert-curated guidelines directly into your agent's context window, focusing on:
* **Modern Browser APIs**: Helping models correctly structure APIs they frequently misuse.
-* **Performance & Accessibility**: Eliminating legacy bloat with clean, native patterns.
+* **Performance & Accessibility**: Preferring platform-level APIs that can be optimized by the browser and include built-in accessibility affordances.
* **Responsible Fallbacks**: Guiding models to use sensible, lightweight fallbacks instead of heavy polyfills or legacy libraries.
## <img src="https://github.com/GoogleChrome/modern-web-guidance/raw/main/.github/img/package.svg" width="24" height="24" style="vertical-align: middle; margin-right: 4px;"> What's Included?
@@ -72,7 +70,7 @@ We cover the past several years of the web platform's new features, all the way
</td>
<td width="33%" valign="top" style="border: none; padding: 6px;">
<h4>♿ Accessibility</h4>
- <p style="font-size: 0.9em; line-height: 1.4;">Hardened patterns (accessible error announcements, keyboard focus management).</p>
+ <p style="font-size: 0.9em; line-height: 1.4;">Important considerations (screen reader and keyboard operability, content navigation and discoverability).</p>
</td>
<td width="33%" valign="top" style="border: none; padding: 6px;">
<h4>🤖 Built-in AI</h4>
@@ -255,7 +253,7 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro
- **[light-dismiss-a-dialog](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/user-experience/light-dismiss-a-dialog.md)**: Create a modal dialog that can be closed via light dismiss (i.e. clicking or tapping outside of the dialog)
- **[manage-recurring-intervals](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/user-experience/manage-recurring-intervals.md)**: Calculate recurring intervals for subscription billings or payroll cycles, automatically adjusting for edge cases such as month-end transitions (e.g., adding one month to January 31st) to ensure accurate period calculations.
- **[model-partial-time-concepts](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/user-experience/model-partial-time-concepts.md)**: Model date and time concepts that inherently lack a standard component (such as a specific year, day, or date) without using arbitrary placeholder values that introduce calculation errors.
-- **[move-dom-element-without-losing-state](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/user-experience/move-dom-element-without-losing-state.md)**: Move or reparent a DOM element without losing important element state, such as interactivity states (:focus/:active), &lt;iframe&gt; loading state, animation/transition state, etc
+- **[move-dom-element-without-losing-state](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/user-experience/move-dom-element-without-losing-state.md)**: Move or reparent a DOM element without losing important element state, such as interactivity states (:focus/:active), `&lt;iframe&gt;` loading state, animation/transition state, etc
- **[navigation-drawer](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/user-experience/navigation-drawer.md)**: Create a navigation drawer component that, when triggered from a menu button, slides in from the side overlayed on top of existing page content, and slides out when dismissed (by swiping away, tapping outside, or pressing escape).
- **[overflow-clipping-control](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/user-experience/overflow-clipping-control.md)**: Adjust the visible clipping boundary of an element to align with the content edge, padding edge, or border edge—or a specified offset from any of these—offering finer-grained control over how content is clipped.
- **[parallax-scroll-effects](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/user-experience/parallax-scroll-effects.md)**: Create scroll-based effects (such as parallax) where foreground and background layers move at different rates, creating a sense of depth as the user scrolls.
@@ -308,9 +306,9 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro
## <img src="https://github.com/GoogleChrome/modern-web-guidance/raw/main/.github/img/cpu.svg" width="24" height="24" style="vertical-align: middle; margin-right: 4px;"> How It Works
-0. **Activation**: The coding agent activates the `modern-web-guidance` skill because of a relevant task. The agent is instructed to use the `modern-web` CLI for web platform queries.
-2. **Local Semantic Search**: The agent runs `modern-web search "<query>"`. The tool matches the query to the best guide using an offline, CPU-efficient TensorFlow.js model (no network calls, no API keys).
-3. **Guide Fetch**: The agent retrieves the guide via `modern-web retrieve <guide-id>`, inserting targeted code patterns, gotchas, and fallbacks directly into its context window.
+1. **Activation**: The coding agent activates the `modern-web-guidance` skill because of a relevant task. The agent is instructed to use the `modern-web-guidance` CLI for web platform queries.
+2. **Local Semantic Search**: The agent runs `modern-web-guidance search "<query>"`. The tool matches the query to the best guide using an offline, CPU-efficient TensorFlow.js model (no network calls, no API keys).
+3. **Guide Fetch**: The agent retrieves the guide via `modern-web-guidance retrieve <guide-id>`, inserting targeted code patterns, gotchas, and fallbacks directly into its context window.
> [!TIP]
> Note: We use `npx` to ensure the content doesn't go stale, but the CLI works offline, completely private and local.
@@ -423,7 +421,7 @@ npx modern-web-guidance@latest install --choose
Google collects anonymous usage statistics (such as search queries, guide retrievals, and installation) to improve the reliability, relevance, and performance of the tool. You can inspect what is collected in [modern-web.ts](https://github.com/GoogleChrome/modern-web-guidance-src/blob/main/serving/bin/modern-web.ts).
> [!TIP]
-> **To Opt-Out:**, set the `DISABLE_TELEMETRY=1` env variable in your shell profile (e.g., `.bashrc` or `.zshrc`):
+> **To Opt-Out:** set the `DISABLE_TELEMETRY=1` env variable in your shell profile (e.g., `.bashrc` or `.zshrc`):
> ```bash
> export DISABLE_TELEMETRY=1
> ```
@@ -432,7 +430,7 @@ Google handles this data in accordance with the [Google Privacy Policy](https://
## <img src="https://github.com/GoogleChrome/modern-web-guidance/raw/main/.github/img/users.svg" width="24" height="24" style="vertical-align: middle; margin-right: 4px;"> Contributors
-If you'd like to contribute to modern-web-guidance, please see [source repo's `CONTRIBUTING.md`](https://github.com/GoogleChrome/modern-web-guidance-src/blob/CONTRIBUTING.md). The `modern-web-guidance` repo is a purely a publish target for clean skills installation.
+If you'd like to contribute to modern-web-guidance, please see the [source repo's `CONTRIBUTING.md`](https://github.com/GoogleChrome/modern-web-guidance-src/blob/main/CONTRIBUTING.md). The `modern-web-guidance` repo is purely a publish target for clean skills installation.
Huge thanks to everyone who has contributed!
diff --git a/gemini-extension.json b/gemini-extension.json
index 6e670a5..dffbda8 100644
--- a/gemini-extension.json
+++ b/gemini-extension.json
@@ -1,7 +1,7 @@
{
"name": "modern-web-guidance",
"description": "Keep your coding agent up to date with the latest web best practices",
- "version": "0.0.170",
+ "version": "0.0.171",
"author": {
"name": "Google Chrome"
}
diff --git a/package.json b/package.json
index 10c8058..3423bb4 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
"displayName": "Modern Web Guidance",
"description": "Keep your agent up to date on the latest web best practices.",
"license": "Apache-2.0",
- "version": "0.0.170",
+ "version": "0.0.171",
"publisher": "GoogleChrome",
"engines": {
"vscode": "^1.90.0",
diff --git a/skills/chrome-extensions/SKILL.md b/skills/chrome-extensions/SKILL.md
index 8f4252d..89046ad 100644
--- a/skills/chrome-extensions/SKILL.md
+++ b/skills/chrome-extensions/SKILL.md
@@ -198,7 +198,7 @@ await chrome.action.setBadgeText({ text: '5' });
`activeTab` grants temporary access to the current tab ONLY when triggered by:
- Clicking the extension action icon
-- A context menu item
+- A context menu item (including the `"tab"` context)
- A keyboard shortcut from the `commands` API
- Accepting an omnibox suggestion
@@ -418,7 +418,7 @@ Update it whenever:
- **Rejection response**: If the user reports a CWS rejection, update the file with the
fix and add a note to Version History
-#### How to fill it out
+### How to fill it out
For each section, pull information from the actual project files:
1. Read `manifest.json` to extract name, version, description, permissions, host_permissions
@@ -431,6 +431,17 @@ Web Store review team rejects vague descriptions. "Makes your life easier" will
"Highlights search results on any webpage and lets you save highlights to a local list" will
pass.
+**Never mention implementation details.** Users care what the extension does for them, not
+how it was built. Strip any mention of APIs, libraries, frameworks, or code patterns:
+
+| ❌ Implementation detail (cut it) | ✅ User benefit (keep it) |
+|-----------------------------------|--------------------------|
+| "Uses a MutationObserver to detect page changes" | "Automatically detects new content as you browse" |
+| "Built with custom elements and Shadow DOM" | "Works seamlessly without affecting page styles" |
+| "Powered by a service worker for background processing" | "Runs quietly in the background without slowing your browser" |
+| "Leverages the chrome.storage.sync API" | "Your settings sync across all your devices" |
+| "Implements declarativeNetRequest for filtering" | "Blocks ads and trackers without reading your page content" |
+
### CHROMEWEBSTORE.md Sections
Read `references/webstore/chromewebstore-template.md` before generating the file — it defines
@@ -510,3 +521,4 @@ Verify EVERY item before delivering:
- [ ] Error handling on all async operations
- [ ] `host_permissions` scoped to specific domains (not `<all_urls>` unless needed)
- [ ] `return true` in `onMessage` listeners with async responses
+- [ ] Any use of `"tab"` in `chrome.contextMenus` `contexts` requires Chrome M150+
diff --git a/skills/chrome-extensions/references/extensions/context-menus.md b/skills/chrome-extensions/references/extensions/context-menus.md
index d718083..d04b3e7 100644
--- a/skills/chrome-extensions/references/extensions/context-menus.md
+++ b/skills/chrome-extensions/references/extensions/context-menus.md
@@ -23,6 +23,13 @@ chrome.runtime.onInstalled.addListener(() => {
title: 'Translate "%s"', // %s = selected text
contexts: ['selection']
});
+
+ // M150+: Context menu for the tab strip (right-clicking a tab)
+ chrome.contextMenus.create({
+ id: 'duplicate-tab',
+ title: 'Custom Duplicate Tab',
+ contexts: ['tab']
+ });
});
```
@@ -37,13 +44,16 @@ chrome.contextMenus.onClicked.addListener((info, tab) => {
case 'translate-selection':
translateText(info.selectionText, tab.id);
break;
+ case 'duplicate-tab':
+ chrome.tabs.duplicate(tab.id); // 'tab' parameter is the clicked tab
+ break;
}
});
```
## Context Types
-`all`, `page`, `frame`, `selection`, `link`, `editable`, `image`, `video`, `audio`, `launcher`, `browser_action`, `action`
+`all`, `page`, `frame`, `selection`, `link`, `editable`, `image`, `video`, `audio`, `launcher`, `browser_action`, `action`, `tab` (M150+)
## Submenus
diff --git a/skills/chrome-extensions/references/webstore/chromewebstore-template.md b/skills/chrome-extensions/references/webstore/chromewebstore-template.md
index 4cfe432..976e9a5 100644
--- a/skills/chrome-extensions/references/webstore/chromewebstore-template.md
+++ b/skills/chrome-extensions/references/webstore/chromewebstore-template.md
@@ -28,6 +28,18 @@ are optional but improve listing quality and approval odds.
Paragraph 3: How to use it (step-by-step)
Paragraph 4: Privacy/permissions note (builds trust)
Paragraph 5: Support/feedback info
+
+ WRITE FROM A USER'S PERSPECTIVE — what the extension does FOR them, not HOW it works.
+ Never mention implementation details: APIs used, libraries, frameworks, code patterns.
+
+ ❌ "Uses a MutationObserver and custom elements to track page changes"
+ ✅ "Automatically detects new content as you scroll"
+
+ ❌ "Powered by a service worker for background processing"
+ ✅ "Runs quietly in the background without slowing your browser"
+
+ ❌ "Implements declarativeNetRequest for network filtering"
+ ✅ "Blocks ads and trackers without reading your page content"
-->
@@ -112,8 +124,7 @@ are optional but improve listing quality and approval odds.
## Privacy Policy
-**Privacy Policy URL** [REQUIRED if collecting data, RECOMMENDED otherwise]
-
+**Privacy Policy URL** [REQUIRED]
<!-- Host this at a publicly accessible URL. GitHub Pages, your website, or a
Notion page all work. See references/webstore/privacy-policy.md for a template. -->
@@ -123,10 +134,6 @@ are optional but improve listing quality and approval odds.
**Visibility**: Public / Unlisted / Private
**Regions**: All regions / [List specific regions]
-**Pricing**: Free / Paid
-
-<!-- Note: Paid extensions require a Google Payments merchant account and physical address. -->
-
## Developer Info
diff --git a/skills/chrome-extensions/references/webstore/store-listing.md b/skills/chrome-extensions/references/webstore/store-listing.md
index 36c5f42..46c7503 100644
--- a/skills/chrome-extensions/references/webstore/store-listing.md
+++ b/skills/chrome-extensions/references/webstore/store-listing.md
@@ -52,6 +52,27 @@ Found a bug? Have a suggestion? Email [email] or open an issue at [URL].
Version [X.Y.Z] — [Brief changelog for latest version]
```
+### The Implementation-Detail Rule
+
+**Never describe how the extension is built.** Potential users are not developers evaluating your stack — they want to know what the extension does for them.
+
+Strip all of the following from every piece of copy:
+
+- Web API names: `MutationObserver`, `IntersectionObserver`, `Service Worker`, `Shadow DOM`, `IndexedDB`, `WebSockets`
+- Chrome API names: `chrome.storage`, `declarativeNetRequest`, `chrome.scripting`, `offscreen document`
+- Framework/library names: React, custom elements, Lit, Webpack, TypeScript
+- Architecture descriptions: "background processing", "event-driven", "declarative"
+
+**Transform every implementation sentence into a user benefit:**
+
+| Before (implementation) | After (user benefit) |
+|-------------------------|----------------------|
+| "Uses a MutationObserver to detect page changes" | "Automatically detects new content as you browse" |
+| "Built with custom elements and Shadow DOM" | "Works seamlessly without affecting page styles" |
+| "Powered by a service worker" | "Runs quietly in the background" |
+| "Your settings are synced via chrome.storage.sync" | "Your settings sync across all your devices" |
+| "Implements declarativeNetRequest for filtering" | "Blocks ads and trackers without reading your page content" |
+
### Why This Structure Works
1. **One-sentence opener** — The reviewer and users both scan the first line. Make it count.
diff --git a/skills/modern-web-guidance/guides/built-in-ai/translator.md b/skills/modern-web-guidance/guides/built-in-ai/translator.md
index 21a35f3..4eea762 100644
--- a/skills/modern-web-guidance/guides/built-in-ai/translator.md
+++ b/skills/modern-web-guidance/guides/built-in-ai/translator.md
@@ -1,4 +1,4 @@
-The **Translator API** allows developers to perform client-side text translation using built-in AI models in Chrome. This approach eliminates the need for cloud-based translation services for ephemeral content, reducing costs and improving privacy by keeping data on the user's device.
+The **Translator API** allows developers to perform client-side text translation using built-in AI models in Chrome and Edge. This approach eliminates the need for cloud-based translation services for ephemeral content, reducing costs and improving privacy by keeping data on the user's device.
## Prerequisites & Requirements
@@ -6,7 +6,8 @@ The **Translator API** allows developers to perform client-side text translation
### Browser Support
- **Chrome:** Version 138+ (Desktop only).
-- **Not Supported:** Mobile (Android/iOS), Edge, Firefox, Safari.
+- **Edge:** Version 148+ (Desktop only).
+- **Not Supported:** Mobile (Android/iOS), Firefox, Safari.
### Hardware Requirements
@@ -14,7 +15,7 @@ To run Gemini Nano and associated models, the system needs:
- **Operating System:** Windows 10/11, macOS 13+, Linux, or ChromeOS (Chromebook
Plus).
-- **Storage:** At least **22 GB** free on the Chrome profile volume.
+- **Storage:** At least **22 GB** free on the profile volume.
- **Memory/CPU:** 16 GB+ RAM and 4+ CPU cores.
- **GPU:** 4 GB+ VRAM (Mandatory for Prompt API with audio).
- **Network:** Required only for the initial download of language packs/models.
diff --git a/skills/modern-web-guidance/guides/forms/autofill-address-form.md b/skills/modern-web-guidance/guides/forms/autofill-address-form.md
index d73084e..70163f9 100644
--- a/skills/modern-web-guidance/guides/forms/autofill-address-form.md
+++ b/skills/modern-web-guidance/guides/forms/autofill-address-form.md
@@ -15,7 +15,7 @@ Make the most of the elements and attributes built for creating forms:
These enable built-in browser functionality, improve accessibility, and add meaning to markup.
-### Use the <label> element to label form fields for data entry
+### Use the `<label>` element to label form fields for data entry
To label an `<input>`, `<select>`, or `<textarea>`, use a `<label>`. Associate a label with an input by giving the label's `for` attribute the same value as the input's `id`.
diff --git a/skills/modern-web-guidance/guides/forms/autofill-payment-form.md b/skills/modern-web-guidance/guides/forms/autofill-payment-form.md
index da21533..1c720c5 100644
--- a/skills/modern-web-guidance/guides/forms/autofill-payment-form.md
+++ b/skills/modern-web-guidance/guides/forms/autofill-payment-form.md
@@ -17,7 +17,7 @@ Make the most of the elements and attributes built for creating forms:
These enable built-in browser functionality, improve accessibility, and add meaning to markup.
-### Use the <label> element to label form fields for data entry
+### Use the `<label>` element to label form fields for data entry
To label an `<input>`, `<select>`, or `<textarea>`, use a `<label>`. Associate a label with an input by giving the label's `for` attribute the same value as the input's `id`.
diff --git a/skills/modern-web-guidance/guides/forms/autofill-sign-in-form.md b/skills/modern-web-guidance/guides/forms/autofill-sign-in-form.md
index b12b92f..a80f995 100644
--- a/skills/modern-web-guidance/guides/forms/autofill-sign-in-form.md
+++ b/skills/modern-web-guidance/guides/forms/autofill-sign-in-form.md
@@ -17,7 +17,7 @@ Make the most of the elements and attributes built for creating forms:
These enable built-in browser functionality, improve accessibility, and add meaning to markup.
-### Use the <label> element to label form fields for data entry
+### Use the `<label>` element to label form fields for data entry
To label an `<input>`, `<select>`, or `<textarea>`, use a `<label>`. Associate a label with an input by giving the label's `for` attribute the same value as the input's `id`.
@@ -57,7 +57,7 @@ This enables browsers to help users by securely storing sign-in details and corr
Validate data entry both in realtime and before form submission. Use `type="email"` for email inputs — the browser will validate the format automatically. Add the `required` attribute to mandatory fields to prevent empty submissions.
-### Put sign-in in its own <form> element
+### Put sign-in in its own `<form>` element
Always use the `<form>` element when you're getting users to enter data
diff --git a/skills/modern-web-guidance/guides/forms/autofill-sign-up-form.md b/skills/modern-web-guidance/guides/forms/autofill-sign-up-form.md
index 2da2661..d055152 100644
--- a/skills/modern-web-guidance/guides/forms/autofill-sign-up-form.md
+++ b/skills/modern-web-guidance/guides/forms/autofill-sign-up-form.md
@@ -17,7 +17,7 @@ Make the most of the elements and attributes built for creating forms:
These enable built-in browser functionality, improve accessibility, and add meaning to markup.
-### Use the <label> element to label form fields for data entry
+### Use the `<label>` element to label form fields for data entry
To label an `<input>`, `<select>`, or `<textarea>`, use a `<label>`. Associate a label with an input by giving the label's `for` attribute the same value as the input's `id`.
@@ -57,7 +57,7 @@ This enables browsers to help users by securely storing sign-up details and corr
Validate data entry both in realtime and before form submission. Use `type="email"` for email inputs — the browser will validate the format automatically. For passwords, use a `pattern` attribute to enforce strength requirements and provide clear error messages when validation fails. Add the `required` attribute to mandatory fields to prevent empty submissions.
-### Put sign-up in its own <form> element
+### Put sign-up in its own `<form>` element
Always use the `<form>` element when you're getting users to enter data
diff --git a/skills/modern-web-guidance/guides/user-experience/deliver-optimized-decorative-images.md b/skills/modern-web-guidance/guides/user-experience/deliver-optimized-decorative-images.md
index ba678aa..204c03f 100644
--- a/skills/modern-web-guidance/guides/user-experience/deliver-optimized-decorative-images.md
+++ b/skills/modern-web-guidance/guides/user-experience/deliver-optimized-decorative-images.md
@@ -1,6 +1,6 @@
Delivering optimized decorative images via CSS improves perceived performance without sacrificing visual quality. By using the `image-set()` CSS function, you can provide the browser with multiple options for a single background or mask image. You can specify modern formats (like AVIF or WebP) alongside different resolutions (like `1x` and `2x`). The browser will dynamically select the smallest compatible image that provides the appropriate pixel density for the user's device.
-**CAUTION**: If the image is likely to be the Largest Contentful Paint (LCP) element (e.g., a large hero banner), be aware that images referenced in CSS via image-set() are not discoverable by the browser's preload scanner. This can significantly delay image loading and harm LCP. For LCP candidates, consider using a standard HTML <img> or <picture> tag instead or alternatively, preloading the image as well using `<link rel=preload>` option with a `media` attribute.
+**CAUTION**: If the image is likely to be the Largest Contentful Paint (LCP) element (e.g., a large hero banner), be aware that images referenced in CSS via image-set() are not discoverable by the browser's preload scanner. This can significantly delay image loading and harm LCP. For LCP candidates, consider using a standard HTML `<img>` or `<picture>` tag instead or alternatively, preloading the image as well using `<link rel=preload>` option with a `media` attribute.
### Implementation
diff --git a/skills/modern-web-guidance/guides/webmcp/agentic-javascript-tools.md b/skills/modern-web-guidance/guides/webmcp/agentic-javascript-tools.md
index 1ee0823..6dd73ba 100644
--- a/skills/modern-web-guidance/guides/webmcp/agentic-javascript-tools.md
+++ b/skills/modern-web-guidance/guides/webmcp/agentic-javascript-tools.md
@@ -1,4 +1,4 @@
-The Imperative API uses `navigator.modelContext.registerTool()` to programmatically define JavaScript tools. This is ideal for Single Page Applications (SPAs) where tools need to be added or removed based on the current route or user state.
+The Imperative API uses `document.modelContext.registerTool()` to programmatically define JavaScript tools. This is ideal for Single Page Applications (SPAs) where tools need to be added or removed based on the current route or user state.
## Registration and Lifecycle
@@ -11,7 +11,7 @@ WebMCP does not provide an `unregisterTool()` method. To unregister a tool, you
```javascript
const controller = new AbortController();
-navigator.modelContext.registerTool({
+document.modelContext.registerTool({
name: "get_user_preferences",
description: "Retrieves the user's saved preferences.",
inputSchema: { type: "object", properties: {} },
@@ -31,7 +31,7 @@ controller.abort();
Parameters (params) are defined using the `inputSchema` property. This must be a **JSON Schema** object that describes the structured data the tool expects.
```javascript
-navigator.modelContext.registerTool({
+document.modelContext.registerTool({
name: "calculate_area",
description: "Calculates the area of a rectangle.",
inputSchema: {
@@ -100,7 +100,7 @@ export function createInventoryTool(inventoryManager) {
* **readOnlyHint**: (Optional) Set to `true` if the tool does not modify any state and only reads data. This helps agents decide when it is safe to call the tool.
* **Return Format**: The `execute` function can return any value (object, array, string, number, boolean). Select a structure that best serves your specific use case while ensuring the content is optimized for the LLM to process. The output may encompass raw data, specific error logs, or direct instructions to influence the agent's next action.
* **Secure Context**: WebMCP requires HTTPS.
-* **Deprecated/Removed**: `unregisterTool()`, `provideContext()`, and `clearContext()` are no longer supported.
+* **Deprecated/Removed**: `navigator.modelContext` (deprecated in Chromium 150), `unregisterTool()`, `provideContext()`, and `clearContext()` are no longer supported.
## Fallback strategies
@@ -109,7 +109,8 @@ navigator.modelContext is not natively supported by any major browser yet.
The WebMCP Imperative API should be used with feature detection to ensure compatibility with browsers that do not yet support WebMCP.
```javascript
-if ('modelContext' in navigator && 'registerTool' in navigator.modelContext) {
+const modelContext = document.modelContext || navigator.modelContext;
+if (modelContext && 'registerTool' in modelContext) {
// Register tools
}
```
diff --git a/skills/modern-web-guidance/guides/webmcp/webmcp.md b/skills/modern-web-guidance/guides/webmcp/webmcp.md
index cae1dc0..b2cd2d8 100644
--- a/skills/modern-web-guidance/guides/webmcp/webmcp.md
+++ b/skills/modern-web-guidance/guides/webmcp/webmcp.md
@@ -10,7 +10,7 @@ Currently, WebMCP **only supports Tools**. It does not support the "Resources" o
## Quick Overview
-- **Imperative API**: Use `navigator.modelContext.registerTool()` for complex logic and dynamic interactions.
+- **Imperative API**: Use `document.modelContext.registerTool()` for complex logic and dynamic interactions.
- **Declarative API**: Annotate standard HTML `<form>` elements with `toolname` and `tooldescription` to turn them into tools.
## Best Practices