From cbbe595e6da64537a6d45b3c08908e8f4010f0aa Mon Sep 17 00:00:00 2001 From: IEvangelist <7679720+IEvangelist@users.noreply.github.com> Date: Wed, 18 Nov 2026 17:23:13 -0600 Subject: [PATCH 1/5] Move repeated inline page scripts, styles, and icons into shared assets - Load the AppHost preference and WCP consent bootstraps as blocking, hashed /_astro/ scripts instead of inlining them in every page. - Bundle the Footer and OsAwareTabs scripts; OsAwareTabs now renders a marker read by a shared module. - Emit all JavaScript as files (no inline module scripts) and set build.inlineStylesheets to 'never'. - Render the sidebar caret and page-action external icon via CSS masks (Starlight / starlight-page-actions patches). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- src/frontend/astro.config.mjs | 9 + src/frontend/eslint.config.mjs | 10 + .../patches/@astrojs__starlight@0.41.3.patch | 51 +- .../starlight-page-actions@0.7.0.patch | 43 +- src/frontend/src/components/OsAwareTabs.astro | 69 +-- .../src/components/starlight/Footer.astro | 318 ++++++------ .../src/components/starlight/Head.astro | 485 +----------------- .../src/scripts/apphost-preferences.inline.js | 135 +++++ src/frontend/src/scripts/os-aware-tabs.ts | 78 +++ .../src/scripts/wcp-consent.inline.js | 346 +++++++++++++ .../unit/custom-components.vitest.test.ts | 13 +- .../navigation-preferences.vitest.test.ts | 16 +- 12 files changed, 850 insertions(+), 723 deletions(-) create mode 100644 src/frontend/src/scripts/apphost-preferences.inline.js create mode 100644 src/frontend/src/scripts/os-aware-tabs.ts create mode 100644 src/frontend/src/scripts/wcp-consent.inline.js diff --git a/src/frontend/astro.config.mjs b/src/frontend/astro.config.mjs index c4b5f17828..c22ce219d9 100644 --- a/src/frontend/astro.config.mjs +++ b/src/frontend/astro.config.mjs @@ -66,6 +66,12 @@ export default defineConfig({ cacheDir: './node_modules/.astro', ...(outDir ? { outDir } : {}), vite: { + build: { + // Astro inlines processed } + initOsAwareTabs(); + document.addEventListener('astro:page-load', initOsAwareTabs); + diff --git a/src/frontend/src/components/starlight/Footer.astro b/src/frontend/src/components/starlight/Footer.astro index 64e546c548..9c55b81575 100644 --- a/src/frontend/src/components/starlight/Footer.astro +++ b/src/frontend/src/components/starlight/Footer.astro @@ -383,12 +383,13 @@ const commit = (import.meta.env.PUBLIC_GIT_COMMIT_ID || import.meta.env.GIT_COMM } - + document.querySelectorAll('a[href]').forEach((a) => { + if (a.hasAttribute('data-brand-license')) return; + try { + const url = new URL(a.getAttribute('href') ?? '', window.location.origin); + if (!/^https?:$/.test(url.protocol)) return; - diff --git a/src/frontend/src/components/starlight/Head.astro b/src/frontend/src/components/starlight/Head.astro index a56cafaece..726e842316 100644 --- a/src/frontend/src/components/starlight/Head.astro +++ b/src/frontend/src/components/starlight/Head.astro @@ -10,6 +10,8 @@ import SiteTour from '../SiteTour.astro'; import { getStructuredData } from '@utils/structured-data'; import { getOgMetadata } from '@utils/page-metadata'; import { deploymentMetadata } from '@utils/deployment-metadata'; +import appHostPreferencesScriptUrl from '@scripts/apphost-preferences.inline.js?url'; +import wcpConsentScriptUrl from '@scripts/wcp-consent.inline.js?url'; // The Poppins weights that text in the first viewport renders with. The same files back the // @font-face rules in site.css, so these resolve to the already-emitted assets. @@ -98,139 +100,7 @@ function computeSourceUrl() { {structuredData && + - + '); + expect(head).not.toContain('var appHostLangLabels'); +}); function root() { const attributes = new Map(); From 70073ea32ea1d7bd9f1486ad3d6d477bec1827d3 Mon Sep 17 00:00:00 2001 From: IEvangelist <7679720+IEvangelist@users.noreply.github.com> Date: Wed, 18 Nov 2026 17:42:54 -0600 Subject: [PATCH 2/5] Serve repeated Starlight icons from a shared SVG sprite Redirect every import of Starlight's Icon component to a wrapper that references common icons (site chrome, sidebar topics, socials, pickers, asides) from a hashed /_astro/ sprite via , falling back to inline markup for any other icon. The sprite is generated from Starlight's icon set (bun run icon-sprite) and a unit test keeps it in sync. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- src/frontend/astro.config.mjs | 8 ++- src/frontend/config/starlight-icon-sprite.mjs | 30 ++++++++ src/frontend/package.json | 1 + src/frontend/patches/README.md | 4 +- src/frontend/scripts/generate-icon-sprite.ts | 11 +++ .../assets/icons/starlight-icons.sprite.svg | 1 + .../src/components/starlight/Icon.astro | 51 +++++++++++++ src/frontend/src/utils/icon-sprite.ts | 71 +++++++++++++++++++ .../unit/custom-components.vitest.test.ts | 4 +- .../tests/unit/icon-sprite.vitest.test.ts | 40 +++++++++++ 10 files changed, 215 insertions(+), 6 deletions(-) create mode 100644 src/frontend/config/starlight-icon-sprite.mjs create mode 100644 src/frontend/scripts/generate-icon-sprite.ts create mode 100644 src/frontend/src/assets/icons/starlight-icons.sprite.svg create mode 100644 src/frontend/src/components/starlight/Icon.astro create mode 100644 src/frontend/src/utils/icon-sprite.ts create mode 100644 src/frontend/tests/unit/icon-sprite.vitest.test.ts diff --git a/src/frontend/astro.config.mjs b/src/frontend/astro.config.mjs index c22ce219d9..b083d84083 100644 --- a/src/frontend/astro.config.mjs +++ b/src/frontend/astro.config.mjs @@ -11,6 +11,7 @@ import { aspireVersionPlaceholdersIntegration } from './config/aspire-version-pl import { remarkAspireVersionPlaceholders } from './config/remark-aspire-version-placeholders.mjs'; import { remarkTypeScriptFirstAppHostTabs } from './config/remark-typescript-first-apphost-tabs.mjs'; import { remarkMermaid } from './config/remark-mermaid.mjs'; +import { starlightIconSprite } from './config/starlight-icon-sprite.mjs'; import catppuccin from '@catppuccin/starlight'; import lunaria from './config/lunaria-starlight.mjs'; import mdx from '@astrojs/mdx'; @@ -66,11 +67,14 @@ export default defineConfig({ cacheDir: './node_modules/.astro', ...(outDir ? { outDir } : {}), vite: { + plugins: [starlightIconSprite()], build: { // Astro inlines processed - +{ + /* + * Before paint, hide cookie controls only if a previous visit established that consent is not + * required here (unknown => visible, so a required region never loses a control). The rest of + * the bootstrap is deferred: it only needs the parsed DOM, and keeping it out of the + * render-blocking path means first paint waits on a single small cached file. + */ +} + +