Keep your coding agent up to date with the latest web best practices
Release v0.0.197
github-actions[bot]341268561baa
diff --git a/.agents/plugins/marketplace.json b/.agents/plugins/marketplace.jsonindex 47002e3..0f378e7 100644--- a/.agents/plugins/marketplace.json+++ b/.agents/plugins/marketplace.json@@ -15,7 +15,7 @@"authentication": "ON_INSTALL"},"category": "Developer Tools",- "version": "0.0.196"+ "version": "0.0.197"}]}diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.jsonindex acbc2f2..704349c 100644--- a/.claude-plugin/marketplace.json+++ b/.claude-plugin/marketplace.json@@ -9,7 +9,7 @@"name": "modern-web-guidance","source": "./","description": "Keep your coding agent up to date with the latest web best practices",- "version": "0.0.196"+ "version": "0.0.197"}]}diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.jsonindex 9bcf681..5896703 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.196",+ "version": "0.0.197","author": {"name": "Google Chrome"}diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.jsonindex 6690100..56776ed 100644--- a/.codex-plugin/plugin.json+++ b/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "modern-web-guidance",- "version": "0.0.196",+ "version": "0.0.197","description": "Keep your coding agent up to date with the latest web best practices","author": {"name": "Google Chrome",diff --git a/.cursor-plugin/plugin.json b/.cursor-plugin/plugin.jsonindex ebbfe04..1631827 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.196",+ "version": "0.0.197","author": {"name": "Google Chrome"}diff --git a/.github/plugin/plugin.json b/.github/plugin/plugin.jsonindex ebbfe04..1631827 100644--- a/.github/plugin/plugin.json+++ b/.github/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.196",+ "version": "0.0.197","author": {"name": "Google Chrome"}diff --git a/.grok-plugin/marketplace.json b/.grok-plugin/marketplace.jsonindex 4e63f69..20612a3 100644--- a/.grok-plugin/marketplace.json+++ b/.grok-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.196"+ "version": "0.0.197"}]}diff --git a/README.md b/README.mdindex 1712672..25b5356 100644--- a/README.md+++ b/README.md@@ -183,7 +183,7 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro</details><details>-<summary><strong>186 real-world developer use cases</strong></summary>+<summary><strong>188 real-world developer use cases</strong></summary><h3>accessibility</h3>@@ -385,6 +385,10 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro- **[spinner](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-components/spinner.md)**: Build a loading spinner that communicates busy state to all users, respects reduced-motion preferences, and animates efficiently.- **[stack-drill-down](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/ui-components/stack-drill-down.md)**: Build full-screen hierarchical navigation that lets users drill down into nested views and swipe or navigate back to return, with browser history kept in sync.+<h3>user-experience</h3>++- **[content-first-noise-reduction](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/user-experience/content-first-noise-reduction.md)**: Maximize content and reduce noise by removing blocking popups, keeping persistent navigation compact, and moving secondary content behind on-demand disclosure.+<h3>visual-design</h3>- **[adapt-scrollbar-to-contrast-preferences](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/visual-design/adapt-scrollbar-to-contrast-preferences.md)**: Enhance scrollbar visibility for users who prefer high-contrast interfaces@@ -418,6 +422,7 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro- **[agentic-forms](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/webmcp/agentic-forms.md)**: Expose client-side functionality as tools to AI agents by annotating standard HTML forms with WebMCP attributes.- **[agentic-javascript-tools](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/webmcp/agentic-javascript-tools.md)**: Programmatically register client-side JavaScript functions as tools for AI agents using the WebMCP Imperative API.+- **[webmcp](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/webmcp/webmcp.md)**: Use this guide to implement WebMCP in browser applications, exposing client-side functionality as tools to AI agents via declarative or imperative APIs.</details><!-- INJECT_SKILL_COVERAGE_END -->@@ -427,6 +432,7 @@ _View an example:_ [the `navigation-drawer` guide](https://github.com/GoogleChro* **Responsible Fallbacks**: We prioritize lightweight, case-specific custom fallbacks (<50 LOC) or conditionally-loaded polyfills instead of heavy third-party bundles.* **Gotchas & Quirks**: We document hidden platform limitations, such as the 64KB payload quota for `fetchLater()` or macOS-specific scrollbar behaviors.* **Baseline-Aware Integration**: We leverage real-time compatibility data from the **Baseline** project so agents can dynamically adapt to current browser support and any browser support preferences.+* **Origin Trial Opt-In Gate**: Guides for experimental Origin Trial APIs are discoverable via search, but gated on `retrieve` so agents do not adopt unstable APIs without consent. Run `npx modern-web-guidance@latest set-allow-origin-trials` in your terminal to opt a project in (writes `{"allowOriginTrials": true}` to `.mwgrc`; set to `false` or delete `.mwgrc` to opt out).## <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@@ -543,16 +549,16 @@ We developed a robust eval harness to ensure that the content is **empirically p<!-- INJECT_EVAL_RESULTS_START -->| Date | Agent + Model | Tasks / Assertions | Unguided → Guided (Uplift) || :--- | :--- | :---: | :---: |+| Nov 2 | codex_cli (gpt-6.1-sol) | 205 / 1729 | 55% → 82% (**+27pp**) |+| Nov 2 | claude_code (opus-5-5) | 205 / 1729 | 58% → 90% (**+32pp**) |+| Nov 1 | antigravity_cli (gemini-4-argon) | 205 / 1705 | 61% → 96% (**+35pp**) |+| Oct 30 | codex_cli (gpt-6.1-sol) | 204 / 1721 | 55% → 84% (**+29pp**) |+| Oct 30 | claude_code (opus-5-5) | 204 / 1721 | 58% → 91% (**+33pp**) |+| Oct 30 | antigravity_cli (gemini-4-argon) | 204 / 1637 | 61% → 96% (**+35pp**) |+| Oct 28 | codex_cli (gpt-6.1-sol) | 198 / 1675 | 56% → 85% (**+29pp**) |+| Oct 28 | claude_code (fable-5-1) | 198 / 1646 | 54% → 90% (**+36pp**) |+| Oct 28 | antigravity_cli (gemini-4-argon) | 197 / 1629 | 60% → 95% (**+35pp**) || Oct 25 | claude_code (sonnet-5-5) | 168 / 1422 | 56% → 90% (**+34pp**) |-| Oct 24 | antigravity_cli (gemini-4-argon) | 168 / 1373 | 65% → 95% (**+30pp**) |-| Oct 23 | codex_cli (gpt-6.1-sol) | 168 / 1422 | 58% → 85% (**+27pp**) |-| Oct 22 | claude_code (sonnet-5-5) | 168 / 1422 | 56% → 86% (**+30pp**) |-| Oct 22 | antigravity_cli (gemini-4-argon) | 172 / 1445 | 68% → 96% (**+28pp**) |-| Oct 20 | codex_cli (gpt-6.1-sol) | 172 / 1450 | 58% → 80% (**+22pp**) |-| Oct 20 | claude_code (sonnet-5-5) | 172 / 1450 | 54% → 89% (**+35pp**) |-| Oct 20 | antigravity_cli (gemini-4-argon) | 172 / 1450 | 65% → 95% (**+30pp**) |-| Oct 19 | codex_cli (gpt-6.1-sol) | 172 / 1445 | 56% → 83% (**+27pp**) |-| Oct 19 | claude_code (sonnet-5-5) | 171 / 1438 | 56% → 88% (**+32pp**) |<!-- INJECT_EVAL_RESULTS_END -->diff --git a/gemini-extension.json b/gemini-extension.jsonindex 9bcf681..5896703 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.196",+ "version": "0.0.197","author": {"name": "Google Chrome"}diff --git a/kimi.plugin.json b/kimi.plugin.jsonindex b47c81a..38537cc 100644--- a/kimi.plugin.json+++ b/kimi.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.196",+ "version": "0.0.197","author": {"name": "Google Chrome"},diff --git a/package.json b/package.jsonindex da5f21b..b4e785f 100644--- a/package.json+++ b/package.json@@ -3,14 +3,14 @@"displayName": "Modern Web Guidance","description": "Keep your agent up to date on the latest web best practices.","license": "Apache-2.0",- "version": "0.0.196",+ "version": "0.0.197","publisher": "GoogleChrome","repository": {"url": "https://github.com/GoogleChrome/modern-web-guidance-src"},"engines": {"vscode": "^1.90.0",- "node": ">=20.0.0"+ "node": ">=22.0.0"},"categories": ["AI",diff --git a/plugin.json b/plugin.jsonindex 4e751e2..57ee48f 100644--- a/plugin.json+++ b/plugin.json@@ -1,7 +1,7 @@{"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json","name": "modern-web-guidance",- "version": "0.0.196",+ "version": "0.0.197","description": "Keep your coding agent up to date with the latest web best practices","author": {"name": "Google Chrome",diff --git a/skills/modern-web-guidance/SKILL.md b/skills/modern-web-guidance/SKILL.mdindex f4e0dbc..6aabbe7 100644--- a/skills/modern-web-guidance/SKILL.md+++ b/skills/modern-web-guidance/SKILL.md@@ -2,31 +2,13 @@name: modern-web-guidancedescription: |Search tool for modern web development best practices. MANDATORY: Execute FIRST for all HTML/CSS and clientside JS tasks. Do NOT skip — web APIs evolve rapidly and training weights contain obsolete patterns.-- Trigger immediately for:- - UI/Layout: Modals/dialogs/popovers, tables, dark mode, anchor positioning, container queries, `:has()`, etc.- - Scroll/Motion: View Transitions, Scroll-driven animations, parallax/reveals, etc.- - Performance: CWV (LCP, INP), content-visibility, Fetch Priority, image optimization, etc.- - System/APIs: Security, passkeys, HTML sanitization, Web Components, dates/timezones, Built-in AI, WebAssembly, etc.- - Frameworks: Standard HTML/CSS/DOM in React, Vue, Angular, etc.- - General Frontend: Forms, validation (`:user-valid`), autofill, accessibility, custom selects, scrollbars, etc.-- DO NOT trigger for:- - Backend: SQL, ORMs, API routes, etc.- - Infra/Scripts: CI/CD, Docker, Actions, Python/Go, Git, etc.- - Tooling/Trivial: Vite, tsconfig, ESLint, tests, copy/renames, 3P docs, etc.+ Trigger immediately for: modals/dialogs/popovers, tables, dark mode, anchor positioning, container queries, view transitions, scroll-driven animations, parallax/reveals, forms, validation, autofill, accessibility, custom selects, scrollbars, CWV (LCP, INP, CLS), content-visibility, fetch priority, image optimization, security, passkeys, HTML sanitization, web components, dates/timezones, built-in AI, WebAssembly, standard HTML/CSS/DOM in frameworks, etc.+ DO NOT trigger for: backend (SQL, ORMs, API routes), infra/scripts (CI/CD, Docker, Actions, Python/Go, Git), or tooling/trivial (Vite, tsconfig, ESLint, tests, copy/renames, 3P docs), etc.---# Modern Web Guidance-A skill to search for specific web development use cases and retrieve their corresponding best practice guides.--## When to use--Must use this skill:-- At the **start** of implementing any web UI, CSS layout/animation, or client-side JS logic (dates/timezones, sanitization, performance, accessibility)—including when fixing UX symptoms (e.g., janky interactions, layout shifts).-- Before creating or updating a component, to check if a standardized modern web pattern already exists.-- To avoid implementing ad-hoc solutions or loading large dependencies unnecessarily.+Search and retrieve standardized modern web best practices at the **start** of implementing or updating any web UI, CSS layout/animation, or client-side JS logic (dates/timezones, sanitization, performance, accessibility, UX fixes) before writing ad-hoc solutions or adding dependencies.## Usage Instructions@@ -37,38 +19,14 @@ Run `modern-web-guidance` directly with `npx` using a **2–5 word action-orient- **Example**: Search `"light dismiss dialog"` or `"responsive data table"`, **not** `"dialog"` (too terse), `"responsive table dark mode"` (compound — split into two searches), or `"close React settings modal on outside click"` (framework/app noise).```sh-npx -y modern-web-guidance@latest search "<query>" --skill-version 2026_10_16-6654652b-```--**Example Output**:-```json-[- {- "id": "optimize-image-priority",- "description": "Optimize the loading priority of Largest Contentful Paint (LCP) candidate images.",- "category": "performance",- "featuresUsed": [ "Fetch priority" ],- "tokenCount": 985,- "similarity": 0.7289- },- {- "id": "defer-rendering-heavy-content",- "description": "Reduce rendering times in content-heavy web pages by deferring rendering for offscreen content.",- "category": "performance",- "featuresUsed": [ "content-visibility", "hidden=\"until-found\"" ],- "tokenCount": 1250,- "similarity": 0.6961- }-]+npx -y modern-web-guidance@latest search "<query>" --skill-version 2026_10_30-58d055df```-> **Note**: Judge results by their `description` fields (not raw `similarity` scores):+> **Note**: Returns `[{ "id", "description" }, ...]`. Judge results by their `description` fields:> - **Match found**: Call `retrieve` directly—do not also run `list`.> - **No match on a web UI/CSS/DOM behavior (or broad UI audit)**: If `search` returns `[]` or unrelated descriptions because your phrasing differed from the catalog (or your task spans multiple categories), run `npx -y modern-web-guidance@latest list` once to check if the pattern is covered under more general terminology.> - **Topic not covered**: If no guide `description` directly matches your task, proceed with your implementation without retry loops or retrieving unrelated guides.-----### Step 2. Retrieve Best PracticesOnce you have relevant `id`(s) from the search results, call `retrieve` to get the full guide(s)—including both specific use-case guides that match your task and any broader discipline guide (e.g., `html`, `css`, `forms`, `accessibility`, `color`, `performance`, `security`) that applies. You can pass multiple IDs separated by commas.@@ -77,12 +35,7 @@ Once you have relevant `id`(s) from the search results, call `retrieve` to get tnpx -y modern-web-guidance@latest retrieve "<id>"```-If the output is truncated, you must repeat the command but redirect to a file and read that file.--**Example Output**:-`The markdown content of the guide describing implementation steps...`-----+If `retrieve` saves large output (> 9.5 KB) to a temporary file to prevent truncation, read that file path in full using your file-reading tool (reading remaining line ranges if needed)—do not use `cat` or `head`.### Step 3. Verify Guidance Compliance@@ -100,37 +53,20 @@ When you consult `modern-web-guidance` for a task, end the response where you de## Using npx / pnpx-- Prefer `pnpx` over `npx` if `pnpm` is available (note: `pnpx` does not use the `-y` flag).-- When requesting tool permissions, allowlist `npx -y modern-web-guidance@latest *` specifically (or `pnpx modern-web-guidance@latest *`), never bare `npx *` or `pnpx *`.-- IMPORTANT: on Windows, using `npx` may fail. Use `npx.cmd ...` instead.-- Fetching and running `modern-web-guidance` requires outbound network access. If running in a sandboxed, permission-gated, or approval-based environment (e.g., Codex, Claude Code), **proactively request approval/allowlisting for the command with network access BEFORE executing it the first time**, avoiding sandbox network timeouts.-- In sandboxed environments where `~/.npm` is read-only or restricted, set `NPM_CONFIG_CACHE=/tmp/npm-cache`.-- If the command hangs due to being offline, try running again in offline mode: `npx --offline …`.-- The `--skill-version` flag is used to determine if this SKILL.md is out of date. If it is, a warning message is logged to stderr.+- **Runner & Permissions**: Prefer `pnpx` over `npx` if `pnpm` is available (`pnpx` does not use `-y`); on Windows, use `npx.cmd`. When requesting tool permissions, allowlist `npx -y modern-web-guidance@latest *` (or `pnpx modern-web-guidance@latest *`) specifically, never bare `npx *` or `pnpx *`.+- **Sandboxes & Network**: Fetching `modern-web-guidance` requires outbound network access. In sandboxed or approval-gated environments (e.g., Codex, Claude Code), **proactively request approval/allowlisting with network access BEFORE the first execution** to avoid timeouts, and set `NPM_CONFIG_CACHE=/tmp/npm-cache` if `~/.npm` is read-only.+- **Offline**: If the command hangs due to being offline, retry with `npx --offline …`.## Guidelines-- Always search **first** to find the most relevant guides.+- Always search **first** to find the most relevant guides. Do not hallucinate guides or ignore them; they represent the preferred local standard for the user's project.- These guides use vanilla HTML/CSS/JS; adapt them to your framework without dropping the modern feature:- **Types**: Spread/cast newly shipped HTML attributes (`{...({ popover: 'hint', interestfor: id, commandfor: id, switch: '' } as any)}`, `[attr.*]`) rather than removing them or merging `@types/react`.- **SSR & Bundlers**: Guard `window`/`HTMLElement` in SSR and load polyfills via bare `import('<pkg>')` in client effects (or set Vite `build.target: 'esnext'` for top-level `await`)—never copy files from `node_modules`.- **DOM, IDs & CSS**: Call `showModal()`/`moveBefore()` via refs on non-VDOM-managed nodes, generate per-instance IDs/`anchor-name`s (`useId()`), and keep `:root` and `@starting-style` top-level/unscoped.-- Do not hallucinate guides or ignore them; they represent the preferred local standard for the user's project.## Interpreting Browser Support & Fallbacks* **Default Behavior**: All guides assume **Baseline Widely available** features are safe to use without fallbacks. For features that are not Baseline widely available, you **MUST** follow the fallback recommendations in the guide, unless the user has specified a custom browser support policy.-* **Custom Policies**: If the user has already defined explicit browser support requirements, use the browser compatibility data in the guide to determine if a fallback can be safely ignored.- - For Baseline YYYY targets, a feature satisfies this target if its "Baseline since" date is <= YYYY.- - **Policy Examples**:- - _"Do not implement feature fallbacks."_ (for exploratory prototypes of the cutting-edge web)- - _"Safari 17.4+"_ (for internal tools targeting macOS or Tauri-based desktop apps)- - _"Never recommend or implement polyfills; if a Baseline Newly Available feature is required for core functionality, provide a lightweight custom fallback or redesign the approach."_ (to minimize bundle size and avoid technical debt)- - _"Assume a modern execution environment where Baseline Newly Available features can be used natively, provided they are strictly feature-detected and degrade gracefully."_ (for progressive enhancement strategies)-* **Reactive Policy Discovery**: Watch for environmental cues to suggest documenting a policy in CLAUDE.md or AGENTS.md. Suggest this if the developer:- - Mentions building for a restricted runtime (e.g., Electron or Tauri).- - Explicitly excludes specific targets (e.g., "we don't support Desktop Chrome").- - Expresses hesitation about polyfill complexity, bundle size, or performance cost.- - Questions if a feature is safe to use without fallbacks.-- No defined policy format. This is an example: `**Browser Support:** Allow Newly Available features, but only adopt custom fallback code that adds <= 20 lines and does not require external dependencies.`+* **Custom Policies**: If the user defines explicit browser support requirements, use the guide's compatibility data to determine if a fallback can be ignored (for `Baseline YYYY` targets, a feature satisfies the target if its "Baseline since" date is `<= YYYY`). Examples: _"Do not implement feature fallbacks"_, _"Safari 17.4+"_, _"Never implement polyfills; use a lightweight custom fallback or redesign"_, or _"Allow Newly Available features if feature-detected with graceful degradation"_.+* **Reactive Policy Discovery**: Suggest documenting a policy in `CLAUDE.md` or `AGENTS.md` (e.g., `**Browser Support:** Allow Newly Available features, but only adopt custom fallback code that adds <= 20 lines and no external dependencies`) if the developer targets a restricted runtime (Electron/Tauri), excludes specific browsers, hesitates over polyfill size/complexity, or asks if a feature is safe without fallbacks.diff --git a/skills/modern-web-guidance/guides/accessibility/accessible-generated-content.md b/skills/modern-web-guidance/guides/accessibility/accessible-generated-content.mdindex e1dcf23..299c9a9 100644--- a/skills/modern-web-guidance/guides/accessibility/accessible-generated-content.md+++ b/skills/modern-web-guidance/guides/accessibility/accessible-generated-content.md@@ -21,3 +21,21 @@ button.save::before {```A screen reader would read it out as "Save save".++## Fallback strategies++Baseline status for Alt text for generated content: Newly available. It's been Baseline since 2024-07-09.+Supported by: Chrome 77 (Sep 2019), Edge 79 (Jan 2020), Firefox 128 (Jul 2024), and Safari 17.4 (Mar 2024).++If your Baseline target includes browsers that do not support the `/` alternative text syntax, precede the declaration with a single-value `content` fallback so unsupported browsers do not drop the entire declaration as invalid CSS:++```css+.more-link::after {+ /* Fallback: render the glyph in browsers without `/` support+ (screen readers there will still announce it) */+ content: " →";+ content: " →" / "";+}+```++For non-empty alternative text (`content: url(...) / "..."`), a single-value `content: url(...)` fallback keeps the image visible in older browsers but drops its alt text. If that label is required in older browsers, put it in the DOM instead (e.g., via a visually hidden `<span>` or `aria-label`) and use a plain `content: url(...)` declaration without `/`.diff --git a/skills/modern-web-guidance/guides/built-in-ai/language-model.md b/skills/modern-web-guidance/guides/built-in-ai/language-model.mdindex 88ec832..cca31d0 100644--- a/skills/modern-web-guidance/guides/built-in-ai/language-model.md+++ b/skills/modern-web-guidance/guides/built-in-ai/language-model.md@@ -183,7 +183,7 @@ Try to be one step ahead by starting the next most likely AI task as soon as you**Don't:** Unless necessary, don't wait for the user to click "Generate" to initialize the session. This leads to a cold start delay, because the model must first load into memory and prepare its execution pipeline.> [!CAUTION]-> **Caution:** For the Prompt API, wait until you have the `initialPrompts` ready before calling `create()`, because these can only be set during session creation.+> For the Prompt API, wait until you have the `initialPrompts` ready before calling `create()`, because these can only be set during session creation.#### Set initial prompts during creationdiff --git a/skills/modern-web-guidance/guides/built-in-ai/prompt-api.md b/skills/modern-web-guidance/guides/built-in-ai/prompt-api.mdindex 88ec832..cca31d0 100644--- a/skills/modern-web-guidance/guides/built-in-ai/prompt-api.md+++ b/skills/modern-web-guidance/guides/built-in-ai/prompt-api.md@@ -183,7 +183,7 @@ Try to be one step ahead by starting the next most likely AI task as soon as you**Don't:** Unless necessary, don't wait for the user to click "Generate" to initialize the session. This leads to a cold start delay, because the model must first load into memory and prepare its execution pipeline.> [!CAUTION]-> **Caution:** For the Prompt API, wait until you have the `initialPrompts` ready before calling `create()`, because these can only be set during session creation.+> For the Prompt API, wait until you have the `initialPrompts` ready before calling `create()`, because these can only be set during session creation.#### Set initial prompts during creationdiff --git a/skills/modern-web-guidance/guides/forms/animated-select-picker.md b/skills/modern-web-guidance/guides/forms/animated-select-picker.mdindex f66fd41..6976832 100644--- a/skills/modern-web-guidance/guides/forms/animated-select-picker.md+++ b/skills/modern-web-guidance/guides/forms/animated-select-picker.md@@ -157,7 +157,7 @@ The following example demonstrates a custom select styled with standard page ani## Fallback strategies-### Fallbacks & browser support for Customizable <select>+### Fallbacks & browser support for Customizable `<select>`Browser support for Customizable <select>: Limited availability.Supported by: Chrome 135 (Apr 2025), Edge 135 (Apr 2025), and Safari 27 (Sep 2026).diff --git a/skills/modern-web-guidance/guides/forms/autofill-highlight-inputs.md b/skills/modern-web-guidance/guides/forms/autofill-highlight-inputs.mdindex 586192e..f3fe6f2 100644--- a/skills/modern-web-guidance/guides/forms/autofill-highlight-inputs.md+++ b/skills/modern-web-guidance/guides/forms/autofill-highlight-inputs.md@@ -1,4 +1,4 @@-# Use the CSS :autofill pseudo-class to highlight form fields that have been autofilled by the browser and not edited by the user+# Highlight browser-autofilled fields the user hasn't edited with CSS :autofillUse the CSS `:autofill` to highlight fields that have (or have not been) autofilled, to help guide the user to successful form completion.diff --git a/skills/modern-web-guidance/guides/forms/branded-select-styling.md b/skills/modern-web-guidance/guides/forms/branded-select-styling.mdindex 52be5a7..ec7533f 100644--- a/skills/modern-web-guidance/guides/forms/branded-select-styling.md+++ b/skills/modern-web-guidance/guides/forms/branded-select-styling.md@@ -93,7 +93,7 @@ The following example demonstrates a custom select styled with a monospace font## Fallback strategies-### Fallbacks & browser support for Customizable <select>+### Fallbacks & browser support for Customizable `<select>`Browser support for Customizable <select>: Limited availability.Supported by: Chrome 135 (Apr 2025), Edge 135 (Apr 2025), and Safari 27 (Sep 2026).diff --git a/skills/modern-web-guidance/guides/forms/custom-select-picker-layouts.md b/skills/modern-web-guidance/guides/forms/custom-select-picker-layouts.mdindex 65cb46c..9dcbc64 100644--- a/skills/modern-web-guidance/guides/forms/custom-select-picker-layouts.md+++ b/skills/modern-web-guidance/guides/forms/custom-select-picker-layouts.md@@ -144,7 +144,7 @@ Otherwise, it may be ultimately necessary to switch to a custom solution using t## Fallback Strategy-### Fallbacks & browser support for Customizable <select>+### Fallbacks & browser support for Customizable `<select>`Browser support for Customizable <select>: Limited availability.Supported by: Chrome 135 (Apr 2025), Edge 135 (Apr 2025), and Safari 27 (Sep 2026).diff --git a/skills/modern-web-guidance/guides/forms/ime-safe-enter-submit.md b/skills/modern-web-guidance/guides/forms/ime-safe-enter-submit.mdindex a263a8e..add93ec 100644--- a/skills/modern-web-guidance/guides/forms/ime-safe-enter-submit.md+++ b/skills/modern-web-guidance/guides/forms/ime-safe-enter-submit.md@@ -60,7 +60,7 @@ If you need to support cross-browser compatibility across older versions of Safa### Strategy 1: Add a `keyCode === 229` check (recommended)-By pairing `event.isComposing` with a check for `event.keyCode === 229`, you can reliably catch Safari's out-of-order confirming `Enter` keydown. Because this is nested under the `event.key === 'Enter'` gate, it is safe from mobile virtual keyboards that might use `229` for normal character layout entry.+During IME composition, browsers report `keyCode: 229` (`VK_PROCESSKEY`) instead of `13` on `keydown`, even while setting `event.key === 'Enter'` on the confirming keystroke. Pairing `event.isComposing` with `event.keyCode === 229` reliably catches Safari's out-of-order confirming `Enter` keydown. (This also means legacy `event.keyCode === 13` handlers are already immune to IME confirmation, whereas migrating them to `event.key === 'Enter'` without `event.isComposing` and `event.keyCode === 229` will introduce premature submission.) Because this check is nested under the `event.key === 'Enter'` gate, it is safe from mobile virtual keyboards that might use `229` for normal character layout entry.```jstextarea.addEventListener('keydown', (event) => {diff --git a/skills/modern-web-guidance/guides/forms/rich-media-picker.md b/skills/modern-web-guidance/guides/forms/rich-media-picker.mdindex 63c51f3..78e087f 100644--- a/skills/modern-web-guidance/guides/forms/rich-media-picker.md+++ b/skills/modern-web-guidance/guides/forms/rich-media-picker.md@@ -111,7 +111,7 @@ select.custom-select option:checked .option-title {## Fallback Strategies-### Fallbacks & browser support for Customizable <select>+### Fallbacks & browser support for Customizable `<select>`Browser support for Customizable <select>: Limited availability.Supported by: Chrome 135 (Apr 2025), Edge 135 (Apr 2025), and Safari 27 (Sep 2026).diff --git a/skills/modern-web-guidance/guides/forms/slider.md b/skills/modern-web-guidance/guides/forms/slider.mdindex 1e3cba1..2e66a71 100644--- a/skills/modern-web-guidance/guides/forms/slider.md+++ b/skills/modern-web-guidance/guides/forms/slider.md@@ -9,7 +9,7 @@ Use a labeled `<input type="range">` rather than recreating a slider with `<div><input type="range" id="range-slider" value="70"/>```-If the value requires a formatted label or unit, expose it in ordinary DOM content and update `aria-valuetext` when changed. Do not use `::before` or `::after` on slider pseudo-elements, as generated content on form controls is not interoperable. If a tooltip that follows the thumb is required, use the `slider-tooltip` (via `npx -y modern-web-guidance@latest retrieve "slider-tooltip"`) guide.+If the value requires a formatted label or unit, expose it in ordinary DOM content and update `aria-valuetext` when changed. Do not use `::before` or `::after` on slider pseudo-elements, as generated content on form controls is not interoperable. If a tooltip that follows the thumb is required, anchor it to the thumb with CSS anchor positioning; see `position-aware-tooltips` (via `npx -y modern-web-guidance@latest retrieve "position-aware-tooltips"`) for tooltips that stay correctly oriented when they flip.## Choose the styling approachdiff --git a/skills/modern-web-guidance/guides/performance/efficient-background-processing.md b/skills/modern-web-guidance/guides/performance/efficient-background-processing.mdindex f78873d..fe59af2 100644--- a/skills/modern-web-guidance/guides/performance/efficient-background-processing.md+++ b/skills/modern-web-guidance/guides/performance/efficient-background-processing.md@@ -44,7 +44,9 @@ Set `content-visibility: auto` on the heavy container and provide a placeholderAdd an event listener for `contentvisibilityautostatechange` to pause or resume background tasks.-> **Important:** The `contentvisibilityautostatechange` event does not bubble in some browser implementations. To handle this event reliably, you must either:+> [!IMPORTANT]+> The `contentvisibilityautostatechange` event does not bubble in some browser implementations. To handle this event reliably, you must either:+>> - Attach the event listener directly to the element that has `content-visibility: auto` applied.> - Use a capturing event listener (`{ capture: true }`) if you are delegating events to a parent container.diff --git a/skills/modern-web-guidance/guides/performance/faster-spa-view-transitions.md b/skills/modern-web-guidance/guides/performance/faster-spa-view-transitions.mdindex e04cd28..f2b0889 100644--- a/skills/modern-web-guidance/guides/performance/faster-spa-view-transitions.md+++ b/skills/modern-web-guidance/guides/performance/faster-spa-view-transitions.md@@ -27,7 +27,8 @@ While this approach offers massive performance benefits, it introduces a specifiSet `content-visibility: hidden` on views that are not currently active.-> **Note:** The `content-visibility: hidden` property hides an element's *contents*, but the element itself remains styled and visible. Its background, borders, padding, and margins will still be painted by the browser.+> [!NOTE]+> The `content-visibility: hidden` property hides an element's *contents*, but the element itself remains styled and visible. Its background, borders, padding, and margins will still be painted by the browser.```css.spa-view.inactive {@@ -41,7 +42,7 @@ Set `content-visibility: hidden` on views that are not currently active.### 2. Manage Focus-When swapping views, ensure you manage keyboard focus correctly to preserve accessibility.+When swapping views, ensure you manage keyboard focus correctly to preserve accessibility. Use the `inert` attribute to ensure interface elements in the hidden content are not included in the keyboard tab order.```javascriptfunction switchToView(viewId) {@@ -49,12 +50,14 @@ function switchToView(viewId) {document.querySelectorAll('.spa-view').forEach(view => {view.classList.add('inactive');view.setAttribute('aria-hidden', 'true');+ view.setAttribute('inert', 'inert');});// Show the target viewconst activeView = document.getElementById(viewId);activeView.classList.remove('inactive');activeView.setAttribute('aria-hidden', 'false');+ activeView.removeAttribute('inert');// MANDATORY: Move focus to the new view to ensure a logical tab-orderactiveView.focus();diff --git a/skills/modern-web-guidance/guides/performance/performance.md b/skills/modern-web-guidance/guides/performance/performance.mdindex 32c6ecc..2a77100 100644--- a/skills/modern-web-guidance/guides/performance/performance.md+++ b/skills/modern-web-guidance/guides/performance/performance.md@@ -142,7 +142,7 @@ Third-party scripts (analytics, ads, chat widgets) are the primary source of mai**HTML: Third-Party Script Execution**```html<!-- 1. Place third-party scripts near the end of the page with the defer attribute -->-<script defer src="http://www.example.com/third-party.js"></script>+<script defer src="https://www.example.com/third-party.js"></script>```## CSS Rendering & Containment Optimizationdiff --git a/skills/modern-web-guidance/guides/security/local-network-access.md b/skills/modern-web-guidance/guides/security/local-network-access.mdindex 262a837..59c5d04 100644--- a/skills/modern-web-guidance/guides/security/local-network-access.md+++ b/skills/modern-web-guidance/guides/security/local-network-access.md@@ -162,7 +162,7 @@ Permissions-Policy: local-network=(self "https://setup.partner.example.com"), lo## Fallback StrategiesBrowser support for Local network access: Limited availability.-Supported by: Chrome 142 (Oct 2025) and Edge 142 (Oct 2025).+Supported by: Chrome 145 (Feb 2026) and Edge 145 (Feb 2026).Unsupported in: Firefox and Safari.If your Baseline target does not support Local Network Access permissions and `targetAddressSpace` options, implement **feature detection with progressive fallback**:diff --git a/skills/modern-web-guidance/guides/security/passkey-management.md b/skills/modern-web-guidance/guides/security/passkey-management.mdindex f258c26..1375dc2 100644--- a/skills/modern-web-guidance/guides/security/passkey-management.md+++ b/skills/modern-web-guidance/guides/security/passkey-management.md@@ -221,6 +221,7 @@ import 'webauthn-polyfills';Browser support for Web authentication signal methods: Limited availability.Supported by: Chrome 132 (Jan 2025), Edge 132 (Jan 2025), and Safari 26 (Sep 2025).Unsupported in: Firefox.+If the browser does not support `PublicKeyCredential.parseRequestOptionsFromJSON`, use the 'webauthn-polyfills':```html@@ -229,7 +230,7 @@ If the browser does not support `PublicKeyCredential.parseRequestOptionsFromJSONawait import('https://unpkg.com/webauthn-polyfills');}</script>- ```+```This will also add support for `PublicKeyCredential.prototype.toJSON`.diff --git a/skills/modern-web-guidance/guides/security/security.md b/skills/modern-web-guidance/guides/security/security.mdindex 4b6f839..364926e 100644--- a/skills/modern-web-guidance/guides/security/security.md+++ b/skills/modern-web-guidance/guides/security/security.md@@ -40,7 +40,7 @@ Guidelines for implementing preventative security measures on the web safely andThe right starting point depends on the application and whether you can update the codebase directly:-- **Auditing and hardening a codebase directly**: Apply Phase 1 code hygiene, wire up Phase 2 reporting (`Reporting-Endpoints` and `report-to`), and enforce Phase 3 headers (`Content-Security-Policy` with nonces/hashes, `'strict-dynamic'`, `'report-sample'`, `object-src 'none'`, `base-uri 'none'`, `frame-ancestors 'self'`, and `require-trusted-types-for 'script'`, plus COOP, CORP, Fetch Metadata, HSTS, `X-Content-Type-Options`, `Referrer-Policy`, and `Permissions-Policy`) directly by updating `<script>` tags, cookies, and server middleware in the same pass.+- **Auditing and hardening a codebase directly**: Apply Phase 1 code hygiene, wire up Phase 2 reporting (`Reporting-Endpoints` and `report-to`), and enforce Phase 3 headers (`Content-Security-Policy` with nonces/hashes, `'strict-dynamic'`, `'report-sample'`, `object-src 'none'`, `base-uri 'none'`, `frame-ancestors 'none'` (or `'self'`), and `require-trusted-types-for 'script'`, plus COOP, CORP, Fetch Metadata, HSTS, `X-Content-Type-Options`, `Referrer-Policy`, and `Permissions-Policy`) directly by updating `<script>` tags, cookies, and server middleware in the same pass.- **Staged rollout on a large production site with unknown third-party dependencies**: Start with Phase 1 quick wins and deploy Phase 2 report-only headers alongside enforced companion policies while collecting violation telemetry, then promote the report-only policies to Phase 3 enforcement.- **Greenfield app or SaaS template / framework defaults**: Ship Phase 1 hygiene and Phase 3 enforced policies by default, with Phase 2 reporting configured so regressions are captured immediately.@@ -88,12 +88,22 @@ Set-Cookie: third_party_var=value; SameSite=None; Secure; Partitioned```### 1.4 Clickjacking Protection (Frame-Ancestors & X-Frame-Options)-Clickjacking protection is easy to deploy, carries extremely low risk of breaking legitimate functionality, and provides immediate defense against malicious UI redressing.-- **DO**: Set the `X-Frame-Options: SAMEORIGIN` header to prevent other sites from embedding your pages in an iframe (or use `DENY` if you should never be embedded).-- **DO**: For fine-grained control, use `frame-ancestors 'self'` (or specified trusted domains) in your CSP header.+Clickjacking protection is easy to deploy, carries extremely low risk of breaking legitimate functionality, and provides immediate defense against malicious UI redressing. Choose the policy tier that matches your framing requirements:+- **DO (Default — no framing needed)**: Set `Content-Security-Policy: frame-ancestors 'none'` alongside `X-Frame-Options: DENY` when your pages never need to be embedded in an iframe.+- **DO (Same-origin framing only)**: Set `Content-Security-Policy: frame-ancestors 'self'` alongside `X-Frame-Options: SAMEORIGIN` when your application embeds its own pages in same-origin iframes.+- **DO (Specific cross-origin framing required)**: Set `Content-Security-Policy: frame-ancestors 'self' https://trusted-partner.com` and **omit `X-Frame-Options`** (`X-Frame-Options` cannot express cross-origin allowlists—`ALLOW-FROM` is obsolete and unsupported—and `DENY` or `SAMEORIGIN` would block the embed in any client that evaluates `X-Frame-Options` without `frame-ancestors`).+- **DO (Arbitrary framing explicitly required)**: Only omit both `frame-ancestors` and `X-Frame-Options` on routes designed as publicly embeddable widgets.```http+# Default (never framed):+Content-Security-Policy: frame-ancestors 'none';+X-Frame-Options: DENY++# Same-origin framing allowed:+Content-Security-Policy: frame-ancestors 'self';X-Frame-Options: SAMEORIGIN++# Specific cross-origin framing allowed (omit X-Frame-Options):Content-Security-Policy: frame-ancestors 'self' https://trusted-partner.com;```@@ -145,7 +155,7 @@ Use "Report-Only" headers to identify potential breakages before they happen.**Example headers:**```httpReporting-Endpoints: default="https://reports.example/default", main-endpoint="https://reports.example/main"-Content-Security-Policy-Report-Only: script-src 'nonce-{RANDOM}' 'strict-dynamic' 'report-sample'; object-src 'none'; base-uri 'none'; frame-ancestors 'self'; require-trusted-types-for 'script'; report-to main-endpoint;+Content-Security-Policy-Report-Only: script-src 'nonce-{RANDOM}' 'strict-dynamic' 'report-sample'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'; require-trusted-types-for 'script'; report-to main-endpoint;```The `'strict-dynamic'`, `https:`, and `'unsafe-inline'` tokens together form a backwards-compatibility ladder: modern browsers honor `'strict-dynamic'` (nonce-propagating) and ignore the others; older browsers fall back to `https:`; very old browsers fall back to `'unsafe-inline'`. The fallbacks are harmless on any browser that supports a stricter token.@@ -196,7 +206,7 @@ When enforcing `Content-Security-Policy`, always keep `Reporting-Endpoints` and- `script-src 'nonce-{RANDOM}' 'strict-dynamic' 'report-sample'` (or SHA-256/384/512 script hashes for static HTML) — the core directive of any CSP and the primary mechanism to prevent XSS.- `object-src 'none'` — blocks plugin-based code execution (`<object>`, `<embed>`).- `base-uri 'none'` — blocks `<base>` tag hijacking of relative URLs.-- `frame-ancestors 'self'` — prevents clickjacking alongside `X-Frame-Options: SAMEORIGIN` (§1.4).+- `frame-ancestors 'none'` (or `'self'` when same-origin framing is needed) — prevents clickjacking alongside `X-Frame-Options: DENY` (or `SAMEORIGIN`; see §1.4).- `require-trusted-types-for 'script'` — enforces Trusted Types runtime checks on DOM XSS sinks (§3.3).- `report-to <endpoint>` — sends violation reports to the endpoint defined in `Reporting-Endpoints`.- *Optional*: `form-action 'self'` prevents form submissions to attacker-controlled origins.@@ -204,7 +214,7 @@ When enforcing `Content-Security-Policy`, always keep `Reporting-Endpoints` and**Enforced Header Example (CSP with reporting):**```httpReporting-Endpoints: main-endpoint="https://reports.example/main"-Content-Security-Policy: script-src 'nonce-{RANDOM}' 'strict-dynamic' 'report-sample'; object-src 'none'; base-uri 'none'; frame-ancestors 'self'; require-trusted-types-for 'script'; report-to main-endpoint;+Content-Security-Policy: script-src 'nonce-{RANDOM}' 'strict-dynamic' 'report-sample'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'; require-trusted-types-for 'script'; report-to main-endpoint;```HTML for nonce-based CSP:@@ -224,7 +234,7 @@ const csp = [`script-src 'nonce-${nonce}' 'strict-dynamic' 'report-sample'`,"object-src 'none'","base-uri 'none'",- "frame-ancestors 'self'",+ "frame-ancestors 'none'", // or "frame-ancestors 'self'" if same-origin framing is needed"require-trusted-types-for 'script'",'report-to main-endpoint',].join('; ');diff --git a/skills/modern-web-guidance/guides/security/trusted-types.md b/skills/modern-web-guidance/guides/security/trusted-types.mdindex 41e6364..121c918 100644--- a/skills/modern-web-guidance/guides/security/trusted-types.md+++ b/skills/modern-web-guidance/guides/security/trusted-types.md@@ -39,7 +39,8 @@ const escapePolicy = trustedTypes.createPolicy('escape-html', {});```-> **Warning:** Character-level HTML escaping (`escapePolicy`) converts all markup into plain text and is **not** a context-aware HTML sanitizer. If you only need plain text, prefer `element.textContent` (which is not a Trusted Types sink). Never interpolate `escapePolicy.createHTML()` output into another HTML template string—such as an unquoted attribute (`<img src=${escaped}>`) or a URL attribute (`<a href="${escaped}">`, where `javascript:` URLs are not neutralized by entity escaping). Use a full HTML sanitizer (`DOMPurify` or `element.setHTML()`, covered in `sanitize-untrusted-html` (via `npx -y modern-web-guidance@latest retrieve "sanitize-untrusted-html"`)) whenever accepting HTML markup or attributes.+> [!WARNING]+> Character-level HTML escaping (`escapePolicy`) converts all markup into plain text and is **not** a context-aware HTML sanitizer. If you only need plain text, prefer `element.textContent` (which is not a Trusted Types sink). Never interpolate `escapePolicy.createHTML()` output into another HTML template string—such as an unquoted attribute (`<img src=${escaped}>`) or a URL attribute (`<a href="${escaped}">`, where `javascript:` URLs are not neutralized by entity escaping). Use a full HTML sanitizer (`DOMPurify` or `element.setHTML()`, covered in `sanitize-untrusted-html` (via `npx -y modern-web-guidance@latest retrieve "sanitize-untrusted-html"`)) whenever accepting HTML markup or attributes.### 2. Using the Policydiff --git a/skills/modern-web-guidance/guides/ui-atoms/scroll-position-aware-elements.md b/skills/modern-web-guidance/guides/ui-atoms/scroll-position-aware-elements.mdindex 44b9dbb..18e405c 100644--- a/skills/modern-web-guidance/guides/ui-atoms/scroll-position-aware-elements.md+++ b/skills/modern-web-guidance/guides/ui-atoms/scroll-position-aware-elements.md@@ -36,7 +36,8 @@ Place the element inside the container and style it. By default, it should be hi}```-> **Important:** Sticky or floating elements hover above the scrollable content. Ensure that the main content has sufficient bottom padding or margin so that the last few elements are not permanently covered by the button when the user scrolls completely to the bottom.+> [!IMPORTANT]+> Sticky or floating elements hover above the scrollable content. Ensure that the main content has sufficient bottom padding or margin so that the last few elements are not permanently covered by the button when the user scrolls completely to the bottom.### 3. Respond to the Scroll Statediff --git a/skills/modern-web-guidance/guides/ui-behaviors/same-document-transitions.md b/skills/modern-web-guidance/guides/ui-behaviors/same-document-transitions.mdindex 0730891..281acc6 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/same-document-transitions.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/same-document-transitions.md@@ -27,7 +27,7 @@ Use the `view-transition-name` CSS property to tell the browser which elements sYou can use multiple `view-transition-name`s to morph multiple pairs of elements. For example, you may want to transition both the product image and title with separate transitions.-Because there are multiple items on the list view, you can not give the all of them the same `view-transition-name`. This can be solved in two ways in a SPA.+Because there are multiple items on the list view, you cannot give all of them the same `view-transition-name`. This can be solved in two ways in a SPA.1. **Dynamic detail page:** Assign each item on the list page a unique `view-transition-name`, and then dynamically apply that name to the matching element on the detail page when the list item is selected, as shown here.diff --git a/skills/modern-web-guidance/guides/ui-behaviors/scoped-component-transitions.md b/skills/modern-web-guidance/guides/ui-behaviors/scoped-component-transitions.mdindex 5b33125..98e4f83 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/scoped-component-transitions.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/scoped-component-transitions.md@@ -22,7 +22,8 @@ The scope element automatically participates in its own view transition becauseWhen the scope clips its overflow (`overflow: hidden`, `scroll`, or `clip`), `::view-transition-group-children(root)` automatically applies `overflow: clip`, preventing transitioning children from bleeding outside the component bounds.-> **Note:** Automatic overflow clipping only applies to the scope element itself (`root`). If a captured element inside the scope clips its own overflow and contains other nested captured elements (for example, a scrollable or clipped `<ul>` inside a `.card`), use Nested View Transition Groups so those nested elements stay clipped to their outer captured container:+> [!NOTE]+> Automatic overflow clipping only applies to the scope element itself (`root`). If a captured element inside the scope clips its own overflow and contains other nested captured elements (for example, a scrollable or clipped `<ul>` inside a `.card`), use Nested View Transition Groups so those nested elements stay clipped to their outer captured container:>> ```css> .card ul {diff --git a/skills/modern-web-guidance/guides/ui-behaviors/swipe-to-remove.md b/skills/modern-web-guidance/guides/ui-behaviors/swipe-to-remove.mdindex bfab204..97f2196 100644--- a/skills/modern-web-guidance/guides/ui-behaviors/swipe-to-remove.md+++ b/skills/modern-web-guidance/guides/ui-behaviors/swipe-to-remove.md@@ -132,7 +132,8 @@ The track configuration is gated behind an `.is-initialized` class on the list iThe action color lives on the spacers (Step 2). The action **icon** lives on the list item itself, anchored to the row's left and right edges.-> **Note:** Throughout this guide, "left" refers to the *left side of the row* (which is revealed by swiping right), and "right" refers to the *right side of the row* (revealed by swiping left).+> [!NOTE]+> Throughout this guide, "left" refers to the *left side of the row* (which is revealed by swiping right), and "right" refers to the *right side of the row* (revealed by swiping left).The placement, sizing, and motion below are a **starting suggestion**, not a requirement. Adjust the icon size, edge insets, threshold-pop scale, transition duration, and even the choice of pseudo-elements vs. real DOM nodes to match your design. The only mechanical requirement is that the icon sits behind the content (so the content can cover it pre-swipe) and inside the list item (so it doesn't scroll with the spacer). Everything else is taste.diff --git a/skills/modern-web-guidance/guides/ui-components/navigation-drawer.md b/skills/modern-web-guidance/guides/ui-components/navigation-drawer.mdindex 6b17dc0..54f2d9d 100644--- a/skills/modern-web-guidance/guides/ui-components/navigation-drawer.md+++ b/skills/modern-web-guidance/guides/ui-components/navigation-drawer.md@@ -357,7 +357,7 @@ Supported by: Chrome 85 (Aug 2020), Edge 85 (Aug 2020), Firefox 128 (Jul 2024),#### Popover API fallback (no `popover` attribute support):-Baseline status for the api.HTMLElement.showPopover capability: Newly available. It's been Baseline since 2024-04-16.+Baseline status for the api.HTMLElement.showPopover capability: Widely available. It's been Baseline since 2024-04-16.Supported by: Chrome 114 (May 2023), Edge 114 (Jun 2023), Firefox 125 (Apr 2024), and Safari 17 (Sep 2023).Because this component uses `popover="manual"` and implements dismissal entirely from JavaScript, it does not depend on the popover API's defining behaviors — light-dismiss, the `popovertarget` attribute, top-layer-managed Escape handling, or focus management. The only popover features it actually uses are top-layer promotion (via `showPopover()`) and the `::backdrop` pseudo-element.diff --git a/skills/modern-web-guidance/guides/ui-components/scrollspy.md b/skills/modern-web-guidance/guides/ui-components/scrollspy.mdindex 6924a2c..d8b1595 100644--- a/skills/modern-web-guidance/guides/ui-components/scrollspy.md+++ b/skills/modern-web-guidance/guides/ui-components/scrollspy.md@@ -104,7 +104,7 @@ For browsers that do not support `scroll-target-group`, you should use a fallbacnavLinks.forEach(link => {const isActive = link.getAttribute('href') === `#${id}`;// Use the escaped colon class for consistent styling- link.classList.toggle('\:target-current', isActive);+ link.classList.toggle('target-current', isActive);link.setAttribute('aria-current', isActive);});}@@ -117,8 +117,8 @@ For browsers that do not support `scroll-target-group`, you should use a fallbac<style>/* Fallback style if :target-current is not supported.- Use :is() to combine the native pseudo-class with a fallback class for older browsers. DO NOT use `nav a:target-current, nav a.\:target-current, as the unrecognized pseudoselector invalidates the entire rule in older browsers. */- nav a:is(:target-current, .\:target-current) {+ Use :is() to combine the native pseudo-class with a fallback class for older browsers. DO NOT use `nav a:target-current, nav a.target-current, as the unrecognized pseudoselector invalidates the entire rule in older browsers. */+ nav a:is(:target-current, .target-current) {color: var(--accent, #007bff);border-bottom-color: var(--accent, #007bff);font-weight: bold;diff --git a/skills/modern-web-guidance/guides/user-experience/content-first-noise-reduction.md b/skills/modern-web-guidance/guides/user-experience/content-first-noise-reduction.mdnew file mode 100644index 0000000..ef13d0f--- /dev/null+++ b/skills/modern-web-guidance/guides/user-experience/content-first-noise-reduction.md@@ -0,0 +1,155 @@+# Maximize content and reduce noise++Users come for the content. Keep the page frame small, move it out of the way while users read, and show secondary content only when asked.++## Implementation++### Don't block or interrupt the user++- DO NOT open newsletter modals, interstitials, or full-screen promos when the page loads. Where possible, remove banners and unrelated content that compete with the main content.+- If a notice is legally required (for example, cookie consent), show it as a small, non-modal bar that covers well under 15% of the viewport, with a visible dismiss button labeled with text such as "Accept" or "Close".+- Match the interruption to the stakes: use a blocking dialog only for consequential actions, such as deleting an account, paying, or editing personal data. Use non-blocking messages for everything else.+- Don't move content while the user reads. Reserve space for images, ads, and embeds before they load (for example, with `width` and `height` attributes), don't insert content above what's on screen, and don't open popovers the user didn't ask for.++### Keep persistent bars compact++Keep every fixed or sticky bar under 12% of the viewport height. Use a single row, and don't stack several sticky bars (announcement, header, and sub-navigation). Move extra items into a popover menu or drawer instead (see below).++### Hide persistent bars while the user scrolls down++Hide the top bar (the site header or navigation bar) while the user scrolls down and bring it back as soon as they scroll up, so it's out of the way while reading but one flick away. A scroll-state container query tracks the scroll direction in CSS, with no script. Hide bottom bars, such as a tab bar, the same way, sliding them down instead of up.++```css+/* The root scroller remembers the direction of the most recent scroll. */+html {+ container-type: scroll-state;+}+.top-bar {+ position: sticky;+ top: 0;+ z-index: 1; /* Example value: keeps positioned content from painting over the bar. */+}+/* Scrolling down: move the bar out of view. transform doesn't change layout, so content doesn't jump.+ (scrollable: top) shows the bar at the very top, even after jumps such as the Home key, which don't update "scrolled". */+@container scroll-state((scrolled: bottom) and (scrollable: top)) {+ .top-bar {+ transform: translateY(-100%);+ }+}+/* Keep the bar visible while it contains keyboard focus. */+.top-bar:focus-within {+ transform: none;+}+/* Example value: at least the bar's height, so in-page link targets don't land under the bar. */+:target {+ scroll-margin-top: 4rem;+}+```++Alternatively, shrink the bar to under 80% of its height as the user scrolls; see `shrinking-header-on-scroll` (via `npx -y modern-web-guidance@latest retrieve "shrinking-header-on-scroll"`).++### Put secondary UI in popovers and drawers++Use the `popover` attribute for menus, overflow actions, tooltips, hover cards, and onboarding tips instead of permanent toolbars or custom JavaScript overlays. A button with `popovertarget` opens and closes the popover on click, <kbd>Enter</kbd>, or <kbd>Space</kbd>. The default `popover="auto"` also closes it on <kbd>Esc</kbd> or a click outside.++```html+<button popovertarget="more-links">More</button>+<!-- Rendered in the top layer, so no z-index management is needed. -->+<nav id="more-links" popover aria-label="More links">+ <a href="/about">About</a>+ <a href="/contact">Contact</a>+</nav>+```++- Popovers open in the center of the screen by default. To place a popover next to its button, see `viewport-aware-dropdowns` (via `npx -y modern-web-guidance@latest retrieve "viewport-aware-dropdowns"`).+- Buttons can also open popovers with `commandfor` and `command="toggle-popover"`; see `declarative-dialog-popover-control` (via `npx -y modern-web-guidance@latest retrieve "declarative-dialog-popover-control"`).+- For larger sets of options, use an off-canvas drawer: a `popover` panel pinned to one side of the screen that slides in over the page (see `navigation-drawer` (via `npx -y modern-web-guidance@latest retrieve "navigation-drawer"`) for swipe-to-close and animation). Show rows of related items as a horizontally scrolling carousel instead of a long stacked list.++### Collapse secondary content with `details`++Put long or rarely needed content (specs, FAQs, fine print) in a `details` element. It starts closed, and its `summary` works with the keyboard and screen readers without JavaScript.++```html+<details>+ <summary>Shipping and returns</summary>+ <p>Free returns within 30 days.</p>+</details>+```++## Fallback strategies++### Scroll-state queries++Browser support for Container scroll-state queries: Limited availability.+Supported by: Chrome 133 (Feb 2025) and Edge 133 (Feb 2025).+Unsupported in: Firefox and Safari.++Without scroll-state queries, the bar never hides, but it stays compact and usable. If your Baseline target includes those browsers, add a small script so the bar hides there too. Browsers that support other scroll-state queries but not `scrolled` also keep the bar visible.++```css+/* Don't hide the bar while it contains keyboard focus. */+.top-bar.is-hidden:not(:focus-within) {+ transform: translateY(-100%);+}+```++```js+// Runs only where scroll-state queries aren't supported. Run it after .top-bar is parsed (for example, in a module script).+if (!CSS.supports('container-type', 'scroll-state')) {+ const bar = document.querySelector('.top-bar');+ let lastY = scrollY;+ addEventListener('scroll', () => {+ // Clamp so rubber-band overscroll at the top or bottom doesn't flip the scroll direction.+ const y = Math.max(0, Math.min(scrollY, document.documentElement.scrollHeight - innerHeight));+ if (y === lastY) return;+ // Hide only after scrolling down past the bar's own height, so it doesn't flicker near the top.+ bar?.classList.toggle('is-hidden', y > lastY && y > bar.offsetHeight);+ lastY = y;+ }, { passive: true });+}+```++### Fallbacks & browser support for Popover++Baseline status for Popover: Newly available. It's been Baseline since 2025-01-27.+Supported by: Chrome 116 (Aug 2023), Edge 116 (Aug 2023), Firefox 125 (Apr 2024), Safari 17 (Sep 2023), and Safari iOS 18.3 (Jan 2025).++The Popover API is mostly **progressive enhancement**, but its defining behaviors — top-layer promotion, light-dismiss, and `popovertarget` invocation — have no CSS-only equivalent. Older browsers need a polyfill, or a manual fallback if you would rather not ship one.++**Polyfill:** To support the `popover` attribute in older browsers, conditionally load [`@oddbird/popover-polyfill`](https://github.com/oddbird/popover-polyfill). **MANDATORY:** Feature detect by checking for the `popover` property on `HTMLElement.prototype`, and load the polyfill **only** when native support is missing — do NOT load it unconditionally.++With a bundler or import map:++```js+// MANDATORY: Feature detect 'popover' on HTMLElement.prototype.+if (!("popover" in HTMLElement.prototype)) {+ import("@oddbird/popover-polyfill");+}+```++Without a bundler, import from a CDN inside a `<script type="module">`:++```html+<script type="module">+ if (!("popover" in HTMLElement.prototype)) {+ import("https://unpkg.com/@oddbird/popover-polyfill@latest/dist/popover.min.js");+ }+</script>+```++**Styling caveat:** The polyfill cannot define the real `:popover-open` pseudo-class, so it applies a `.\:popover-open` class instead. **MANDATORY:** Combine the two with `:is()` or `:where()`, otherwise browsers that lack `:popover-open` discard the entire rule:++```css+[popover]:is(:popover-open, .\:popover-open) {+ display: block;+}+```++Alternatively, for a legacy fallback without a polyfill, use `position: fixed` and manually calculate coordinates via `getBoundingClientRect()` or rely on default positioning with `inset: auto` if that's acceptable for the use case.++### Invoker commands++Baseline status for Invoker commands: Newly available. It's been Baseline since 2025-12-12.+Supported by: Chrome 135 (Apr 2025), Edge 135 (Apr 2025), Firefox 144 (Oct 2025), and Safari 26.2 (Dec 2025).++Browsers without invoker commands ignore `commandfor`, so the button does nothing there. Prefer `popovertarget`, which works wherever popovers do. If you use `commandfor`, dynamically import `invokers-polyfill` (through your bundler, or from a CDN if you don't use one) only when `'commandForElement' in HTMLButtonElement.prototype` is false.diff --git a/skills/modern-web-guidance/guides/visual-design/custom-text-decorations.md b/skills/modern-web-guidance/guides/visual-design/custom-text-decorations.mdindex f255eb7..2040149 100644--- a/skills/modern-web-guidance/guides/visual-design/custom-text-decorations.md+++ b/skills/modern-web-guidance/guides/visual-design/custom-text-decorations.md@@ -162,8 +162,6 @@ Use a pseudo-element when the line must be a shape `text-decoration` cannot draw}```-For a freeform path or a draw-on that follows the stroke, see `line-drawing-animation` (via `npx -y modern-web-guidance@latest retrieve "line-drawing-animation"`).-## Outline text with a box insteadTwo box properties decorate text by outlining it rather than running a line along it. Give the text padding so the outline does not touch it.@@ -206,10 +204,10 @@ When only the corners need a different shape, such as a beveled, scooped, or not## Choose a technique* **`text-decoration`** (line, ink skipping, spaces, inset): the line should run along the text, wrap with it, and follow its font metrics. This is the default choice.-* **Pseudo-element with `border-shape` and `clip-path`**: the line is a custom shape or needs a draw-on animation. Choose it only when `text-decoration-style` cannot produce the look, because it needs extra positioning. For vector path animations, see `line-drawing-animation` (via `npx -y modern-web-guidance@latest retrieve "line-drawing-animation"`).-* **`background-clip: border-area`**: the text needs a gradient outline. Use plain `border-color` when a solid outline is enough. For complete gradient border styling, see `gradient-borders` (via `npx -y modern-web-guidance@latest retrieve "gradient-borders"`).+* **Pseudo-element with `border-shape` and `clip-path`**: the line is a custom shape or needs a draw-on animation. Choose it only when `text-decoration-style` cannot produce the look, because it needs extra positioning.+* **`background-clip: border-area`**: the text needs a gradient outline. Use plain `border-color` when a solid outline is enough.* **`corner-shape`**: only the corners need a different shape, such as beveled, scooped, or notched. Pair it with `border-radius`, which sets the corner size.-* **`border-shape`**: the outline needs a shape `border-radius` cannot draw, such as a tag or arrow. Use `border-radius` when rounded corners are enough. For shaped element styling, see `element-shape` (via `npx -y modern-web-guidance@latest retrieve "element-shape"`).+* **`border-shape`**: the outline needs a shape `border-radius` cannot draw, such as a tag or arrow. Use `border-radius` when rounded corners are enough.* **Inset hover reveal**: worth adding when a link needs a hover affordance beyond a color change. Skip it for text that is not interactive.## Fallback Strategiesdiff --git a/skills/modern-web-guidance/guides/visual-design/equal-width-text-lines.md b/skills/modern-web-guidance/guides/visual-design/equal-width-text-lines.mdindex 99733d1..8ac4229 100644--- a/skills/modern-web-guidance/guides/visual-design/equal-width-text-lines.md+++ b/skills/modern-web-guidance/guides/visual-design/equal-width-text-lines.md@@ -3,7 +3,7 @@Poster-style lockups where each line is scaled so it spans the container's full width can create visually striking headings.Using `text-fit`, the browser scales each line during layout, so it stays correct on resize, copy changes, and font load.-For a single line filling its container (e.g. a heading or pull quote), see `fit-text-to-container` (via `npx -y modern-web-guidance@latest retrieve "fit-text-to-container"`) instead.+For a single line filling its container (e.g. a heading or pull quote), apply `text-fit` to that element directly; this guide covers multi-line lockups.## Basic implementationdiff --git a/skills/modern-web-guidance/guides/visual-design/visually-texture-content.md b/skills/modern-web-guidance/guides/visual-design/visually-texture-content.mdindex 92eeffa..4bbe1d2 100644--- a/skills/modern-web-guidance/guides/visual-design/visually-texture-content.md+++ b/skills/modern-web-guidance/guides/visual-design/visually-texture-content.md@@ -55,7 +55,8 @@ By default, CSS masks use `mask-mode: match-source`. This means the browser auto| **Direct Image File** (e.g. PNG, SVG file) | `alpha` | Opacity is determined by transparency. **Opaque** parts reveal content, and **transparent** parts hide it. || **CSS Gradient** | `alpha` | Opacity is determined by transparency. **Opaque** colors (like `black`) reveal content, and **transparent** colors hide it. |-> **Note:** You can explicitly override the default mask mode using the `mask-mode` CSS property (e.g., `mask-mode: luminance;` or `mask-mode: alpha;`).+> [!NOTE]+> You can explicitly override the default mask mode using the `mask-mode` CSS property (e.g., `mask-mode: luminance;` or `mask-mode: alpha;`).## Fallback strategiesBaseline status for Masks: Widely available. It's been Baseline since 2023-12-07.diff --git a/skills/modern-web-guidance/guides/wasm/cpp-on-the-web.md b/skills/modern-web-guidance/guides/wasm/cpp-on-the-web.mdindex ebb90f0..b42460a 100644--- a/skills/modern-web-guidance/guides/wasm/cpp-on-the-web.md+++ b/skills/modern-web-guidance/guides/wasm/cpp-on-the-web.md@@ -1,73 +1,186 @@# Compiling C and C++ to WebAssembly with Emscripten-Use Emscripten to compile C and C++ into high-performance WebAssembly (Wasm)-modules for the browser.+Use Emscripten (`emcc` and `em++`) to compile C and C++ into high-performance+WebAssembly (Wasm) modules for the browser.++## 1. Recommended Emscripten Compilation Flags++When compiling and linking with `emcc` or `em++`, use modern modular flags:++- `-sSTRICT`: Opt into strict modern Emscripten behavior and disable deprecated+ or legacy compatibility features.+- `-sEXPORT_ES6`: Emit a standard ES6 module (`import`/`export`). This option+ automatically implies `-sMODULARIZE`, encapsulating generated code so it does+ not pollute the global namespace.+- `-sENVIRONMENT=web` (or `-sENVIRONMENT=worker` when running solely inside a+ Web Worker, or `-sENVIRONMENT=web,worker` for both): Strip Node.js and shell+ runtime support code to minimize bundle size.+- `-sALLOW_MEMORY_GROWTH`: Allow the WebAssembly linear memory heap to expand+ dynamically when allocations exceed the initial heap size.+- `-Werror -Wall`: Treat compiler warnings as errors to catch C/C++ bugs and+ invalid compiler settings early.+- `-O3`, `-Os`, or `-Oz` with `-flto`: In release builds, choose `-O3` when+ runtime performance is most critical, or `-Os` / `-Oz` when minimizing binary+ payload size is the priority. Pass `-flto` during both compilation and+ linking for Link-Time Optimization.++### Command-Line Style++Keep `emcc` and `em++` invocations clean, minimal, and consistent:++- **Omit settings that are enabled by default**: Do not pass redundant flags+ that are already default in modern Emscripten, such as `-sWASM`, or+ `-sMODULARIZE` when `-sEXPORT_ES6` is already specified.+- **Omit the `=1` suffix on boolean `-s` flags**: Write `-sSTRICT`,+ `-sEXPORT_ES6`, and `-sALLOW_MEMORY_GROWTH` rather than `-sSTRICT=1`,+ `-sEXPORT_ES6=1`, or `-sALLOW_MEMORY_GROWTH=1`.+- **Prefer standard compiler flags over Emscripten-specific ones**: Use+ `-pthread` instead of `-sUSE_PTHREADS`, and `-m64` instead of `-sMEMORY64`.+- **Use simple comma-separated lists**: For list-based settings, pass+ comma-separated values without brackets or quotes (for example,+ `-sEXPORTED_FUNCTIONS=_render,_malloc,_free` and+ `-sEXPORTED_RUNTIME_METHODS=HEAPU8`) rather than JSON arrays like+ `-sEXPORTED_FUNCTIONS=['_render','_malloc','_free']`.+- **Use response files for long lists**: If an export list is large, pass a+ response file (`@filename`) instead of a long inline list (for example,+ `-sEXPORTED_FUNCTIONS=@exported_funcs.txt`).+- **Use separate compilation for multi-file projects**: Compile `.c` / `.cpp`+ sources to `.o` object files (`em++ -c`) before linking them into the final+ module rather than combining everything into a single monolithic invocation.-## 1. Modern Emscripten Compilation Flags--When compiling and linking with `emcc` or `em++`, always use modern modular-flags:--- `-sEXPORT_ES6`: Emits standard ES6 module syntax (`import`/`export`) rather- than legacy global objects. This automatically sets `-sMODULARIZE`.-- `-sENVIRONMENT=web`: Strips Node.js/shell runtime code to minimize bundle- size.-- `-sSTRICT`: Enforces modern Emscripten defaults and fails on deprecated- flags.-- `-sALLOW_MEMORY_GROWTH`: Allows the WebAssembly linear memory heap to expand- dynamically when allocating memory.-- `-Oz` (or `-O3`) + `-flto`: Optimizes for minimal payload size in release builds.--## 2. Avoid blocking the main thread--If a call into WebAssembly is likely to take a significant amount of time (i.e.-more than a few milliseconds) it should **not** be called on the main browser-thread.--To avoid running such code on the main browser thread there are several possible-approaches:--1. Run the whole WebAssembly program in a Web Worker. This is often the- simplest solution since it doesn't involve setting up SharedArrayBuffer- access, or changing the program source.--2. Use pthreads or Wasm Workers. This allows the work to be shared across- many workers but requires SharedArrayBuffer access which can involve adding- COOP/COEP HTTP headers.--3. Refactor the C/C++ code to avoid long running calls. For example slicing- the work into small pieces that can be called from `requestIdleCallback`.--## 3. Pay attention for runtime warnings and errors--Make sure you actually test the resulting WebAssembly program and that no-warnings or errors are generated on the console.--Build and run the programs with `-sASSERTIONS` enabled and fix any runtime-failures that are produced.--## 4. Avoid dynamic linking if possible--Emscripten works best with static libraries (`.a`). Shared libraries (`.so`,-`.dylib`, `.dll`) are less useful in browser deployment and can complicate-things unnecessarily.+```bash+# Compile C++ source to an object file+em++ -c renderer.cpp -o renderer.o -O3 -flto -Werror -Wall++# Link into an ES6 WebAssembly module targeting a Web Worker+em++ renderer.o -o renderer.js \+ -O3 -flto \+ -sSTRICT \+ -sEXPORT_ES6 \+ -sENVIRONMENT=worker \+ -sALLOW_MEMORY_GROWTH \+ -sEXPORTED_FUNCTIONS=_render_frame,_malloc,_free \+ -sEXPORTED_RUNTIME_METHODS=HEAPU8+```-## 5. Porting Existing C/C++ Libraries+### Debug vs. Release Profiles++Keep compile and link flags consistent within each build profile, and never+ship debug information in production:++- **Release builds**: Use `-O3`, `-Os`, or `-Oz` combined with `-flto` on both+ compile and link steps, and omit `-g` and `-sASSERTIONS`. Add `--closure=1`+ when linking to minify the generated JavaScript glue code unless an external+ bundler already minifies it.+- **Debug builds**: Use `-g` when compiling and `-g`, `-gline-tables-only`, or+ `-gsource-map` when linking, alongside `-sASSERTIONS`. Avoid optimization+ flags (`-O2`, `-O3`, `-Os`, `-Oz`) and `-flto` in debug builds for faster+ compilation and accurate source-level debugging.++## 2. JavaScript-WebAssembly Boundary Efficiency++Avoid high-frequency calls across the JavaScript-WebAssembly boundary. Calling+an exported Wasm function per pixel, per audio sample, or per vertex incurs+boundary overhead that negates Wasm performance gains.++Instead, design C/C++ entry points to process entire buffers or memory regions+in a single call and read or write the contiguous buffer in linear memory:++```js+import initRenderer from './renderer.js';++const wasm = await initRenderer();+const byteLength = width * height * 4;+const ptr = wasm._malloc(byteLength);++try {+ wasm._render_frame(ptr, width, height, samples);+ const pixels = new Uint8ClampedArray(+ wasm.HEAPU8.buffer,+ ptr,+ byteLength,+ ).slice();+ self.postMessage({ pixels, width, height }, [pixels.buffer]);+} finally {+ wasm._free(ptr);+}+```-When integrating existing C/C++ libraries with standard build systems:+Note: Accessing `wasm.HEAPU8.buffer` directly after calls that may grow memory+requires reading `wasm.HEAPU8` fresh after the Wasm call returns, because+`-sALLOW_MEMORY_GROWTH` detaches the previous `ArrayBuffer` when resizing.++## 3. Avoid Blocking the Main Thread++The browser relies on cooperative multitasking on the main UI thread. Any+WebAssembly call that takes more than a few milliseconds (such as image+rendering, ray tracing, physics simulation, or heavy parsing) **must not** run+synchronously on the main thread, or it will freeze page rendering and input.++Use one of these approaches to keep the UI responsive:++1. **Run the WebAssembly module in a Web Worker**: Instantiate and call the+ ES6 Wasm module inside a dedicated module Worker+ (`new Worker(new URL('./worker.js', import.meta.url), { type: 'module' })`),+ and pass rendered buffers back via `postMessage` with transferable+ `ArrayBuffer` objects.+2. **Use multithreading (`-pthread`)**: Offload heavy compute across background+ workers using standard POSIX threads. Note that `-pthread` requires+ `SharedArrayBuffer`, which requires serving the page in a cross-origin+ isolated context (`Cross-Origin-Opener-Policy: same-origin` and+ `Cross-Origin-Embedder-Policy: require-corp`).+3. **Yield to the browser event loop**: Restructure continuous loops in C/C+++ to run one frame at a time via `emscripten_set_main_loop`, or use+ JavaScript Promise Integration (`-sJSPI`) / Asyncify (`-sASYNCIFY`) when+ synchronous C/C++ code must pause for asynchronous JavaScript APIs.++## 4. Test Runtime Execution and Memory Limits++Always run and verify the compiled WebAssembly module in a real browser+environment and confirm that no warnings or unhandled errors appear in the+console:++- **Validate with `-sASSERTIONS` during development**: Build and test with+ `-sASSERTIONS` enabled to catch invalid memory accesses, missing exports, or+ ABI mismatches early, then remove `-sASSERTIONS` for the final release build.+- **Watch for stack overflows in recursive C/C++ code**: Emscripten's default+ execution stack size (`-sSTACK_SIZE`) is 64 KB, which is much smaller than+ native OS stacks. Deeply recursive algorithms (such as recursive ray tracers+ or tree traversals) can overflow the stack and corrupt linear memory unless+ converted to an iterative loop or linked with a larger stack (for example,+ `-sSTACK_SIZE=1MB`).++## 5. Avoid Dynamic Linking if Possible++Emscripten works best with static linking and static archive libraries (`.a`).+Shared libraries (`.so`, `.dylib`, `.dll`) and dynamic linking (`-sMAIN_MODULE`+/ `-sSIDE_MODULE`) add code-size and runtime overhead and should be avoided+unless runtime plugin loading is strictly required.++## 6. Porting Existing C/C++ Libraries and Build Integration++When integrating C/C++ compilation into a web application project, wire the+`emcc` / `em++` build into the project's build pipeline (such as the `"build"`+script in `package.json`) so that building the project compiles the WebAssembly+artifacts before bundling.++When building third-party C/C++ libraries with existing build systems:### CMake Projects-Wrap CMake commands with `emcmake` and `emmake`:+Wrap `cmake` and `make` with `emcmake` and `emmake`:+```bash-mkdir build && cd build+mkdir -p build && cd buildemcmake cmake .. -DCMAKE_BUILD_TYPE=Releaseemmake make```### Autoconf / Make Projects-Use `emconfigure` to set cross-compilation toolchain targets:+Use `emconfigure` to configure cross-compilation toolchain targets and disable+shared libraries:+```bashemconfigure ./configure --host=wasm32-unknown-emscripten --disable-sharedemmake makediff --git a/skills/modern-web-guidance/guides/webmcp/webmcp.md b/skills/modern-web-guidance/guides/webmcp/webmcp.mdindex 93f3678..f8e7c70 100644--- a/skills/modern-web-guidance/guides/webmcp/webmcp.md+++ b/skills/modern-web-guidance/guides/webmcp/webmcp.md@@ -1,4 +1,4 @@-# WebMCP (Web Model Context Protocol)+# WebMCPWebMCP is a browser-native JavaScript API that allows web pages to expose their client-side functionality as structured "tools" to AI agents, browser assistants, and assistive technologies.