Skip to content

Serve the CSS as cached files, and load page CSS only where used - #93

Merged
RobbieTheWagner merged 2 commits into
media-redesignfrom
fix/css-weight
Nov 30, 2026
Merged

RobbieTheWagner merged 2 commits into
media-redesignfrom
fix/css-weight

Conversation

@RobbieTheWagner

Copy link
Copy Markdown
Member

Why

The goal is to merge media-redesign into main with confidence. The pre-merge review found that every page inlines all of the site's CSS: about 282 KB raw, 54 KB gzipped (main ships 18.5 KB gzipped). build.inlineStylesheets: 'always' put the whole sheet in a <style> on all 531 pages, so no visit could cache it. global.css also pulled the explorer and episode styles into every page, /about/ included.

'always' came from "Always inline stylesheets" (da6b1ff, September 2025). The commit has no message body and was made when the CSS was a few KB. Nothing in the history ties it to view transitions or the persisted dock, and the client-side navigation check below shows the dock and page styles arriving correctly without it.

What changed

  • Cached, linked stylesheets. The integration now sets inlineStylesheets: 'auto'. Astro links the stylesheets as hashed /_astro/*.css files, which the browser caches across pages. Only the 2.1 KB of @font-face stays inline.
  • Page CSS loads only on the pages that use it. explorer.css is now imported by the home page only. episode.css is imported by the episode, About, Contact and For LLMs pages. Both use @reference './tailwind.css' so --spacing() still compiles.
  • Overrides no longer depend on load order. On a full load Astro links a page's own sheet before the shared one. After a client-side navigation it comes after. Rules that override a shared class used to win by coming later, so each now also names the class it overrides and wins on specificity: .icon-button.xp-top, .person-face.xp-pick-face, .PropFLIP.xp-text, .PropFLIP:is(.xp-facts, .xp-title), .PropFLIP.ep-person, .PropFLIP.ep-who-box, .button-secondary.ep-more, and .stage on the narrow-script line size. The segmented control's thumb drops data-⚓️-transition="glide", because its own transition always overrode it. A comment at the top of each page sheet explains the rule.
  • 14 utility-only blocks are now Tailwind classes. These are .xp-seg, .xp-chip, .person-chip, .person-fact, .person-speaking, .rail-label, .rail-fly-title, .platforms, .glyph, .empty, .island-more-pop, .xp-fading-text, .xp-fading-card and .ep-split-gauge. Each element keeps its class name as the customCss hook. tokens.css's .sr-only is deleted in favour of Tailwind's own. A block was moved only if no unlayered rule that used to lose to it would beat the utilities. That ruled out .platform, because anchored-auto-layout's [data-⚓️-fill] sizes it, and .mini-button, .link-on and .stage-frame, which interactions.css, a and .PropFLIP would override.

Verification

All of these ran against pnpm build output from this branch and from origin/media-redesign.

CSS per page, raw / gzip, measured from the built HTML and the files it links:

page before: inline after: linked (inline is 2.1 / 0.6 KB fonts) HTML gzip before → after
/ 282.4 / 53.9 KB 216.3 / 41.5 shared + 41.3 / 9.1 explorer 180.3 → 129.6 KB
episode 282.4 / 53.9 KB 216.3 / 41.5 shared + 21.9 / 5.3 episode 105.5 → 52.0 KB
/about/ 282.4 / 53.9 KB 216.3 / 41.5 shared + 21.9 / 5.3 episode 75.3 → 21.6 KB
/contact/ 282.4 / 53.9 KB 216.3 / 41.5 shared + 21.9 / 5.3 episode 69.0 → 15.5 KB
/404 282.4 / 53.9 KB 216.3 / 41.5 shared

Inline <style> across all 531 pages went from 146.4 MB to 1.1 MB. After the first page, the shared 41.5 KB comes from cache, so the next page costs at most its own 5 to 9 KB sheet.

  • Rendering is unchanged. Every element's computed style and a full-page screenshot were compared before and after, for /, an episode, /about/ and /contact/, at 1440 and 390px.
    • /, the episode and About: 0 pixels differ.
    • Contact: 21 of 1.3M pixels differ at 1440 and 62 of 366k at 390. Both are antialiasing on rounded edges. A run of the same build against itself gives 0.
    • The remaining computed-style differences have no visual effect: .sr-only borders are now width 0 instead of style none, and it clips with clip-path instead of clip; rounded-full computes to a different value than 999px; .person-chip's decoration thickness changed, but it has no underline.
  • Load-order check. A DOM check listed every element on these pages that a page-sheet rule and a shared rule both match at equal specificity. Before the fixes it found 9 such pairs that changed which rule wins. After them, it finds two pairs that set identical values.
  • Client-side navigation. Navigating / → episode → / → /about/ → episode with the ClientRouter keeps the same document. Each step adds the right page sheet and drops the old one, and the explorer grid and the episode bar are styled after each step.
  • pnpm lint passes. pnpm test:unit passes 273 of 273. pnpm build passes, astro check included.
  • On chromium, shell.spec.ts, explorer.spec.ts and episode.spec.ts pass 83 of 83, against a dev server on its own port. The first attempt had a DNS failure fetching the RSS feed, which crashed the dev server. The rerun passed.

One behavior to know

A site's customCss still loads after global.css. Against explorer.css and episode.css, though, it now wins ties only on a full page load, because after a client-side navigation the page sheet lands after it. The documented use, setting theme variables on :root, is unaffected, because those variables live in tokens.css. A customCss rule that restyles an explorer or episode selector needs higher specificity than the built-in one.

🤖 Generated with Claude Code

Every page inlined all 282 KB (54 KB gzipped) of the CSS, uncached, so all
531 pages carried it. The integration now lets Astro link the stylesheets
as hashed files ('auto'), which browsers cache across pages.

explorer.css (home) and episode.css (episode, About, Contact, For LLMs)
leave global.css and are imported by the pages that use them. Astro links
a page's own sheet ahead of the shared one on a full load, and after it
on a client-side navigation, so the rules in them that override a shared
class (.icon-button, .person-face, .PropFLIP, .button-secondary, the
stage's long-line size) now outrank it by specificity instead of by
position. The segmented control's thumb drops a glide transition its own
transition always overrode.

Fourteen single-class blocks of plain utility properties move to Tailwind
classes in the markup, keeping the class itself as the customCss hook.
Tailwind's own sr-only replaces the copy in tokens.css.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
starpod Ready Ready Preview Nov 30, 2026 3:36pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1d96fdd and 4fa57f0.

Files selected for processing: 29

  • packages/starpod/src/components/EpisodeList.astro
  • packages/starpod/src/components/Hosts.astro
  • packages/starpod/src/components/Platforms.astro
  • packages/starpod/src/components/SearchDialog.tsx
  • packages/starpod/src/components/episode/People.astro
  • packages/starpod/src/components/episode/SpeakerCard.tsx
  • packages/starpod/src/components/episode/SponsorCards.astro
  • packages/starpod/src/components/episode/split.ts
  • packages/starpod/src/components/explorer/Card.astro
  • packages/starpod/src/components/explorer/Hero.astro
  • packages/starpod/src/components/explorer/Toolbar.astro
  • packages/starpod/src/components/explorer/explorer.ts
  • packages/starpod/src/components/media/Island.tsx
  • packages/starpod/src/components/media/PlayGlyph.tsx
  • packages/starpod/src/index.ts
  • packages/starpod/src/layouts/Layout.astro
  • packages/starpod/src/pages/[episode].astro
  • packages/starpod/src/pages/about.astro
  • packages/starpod/src/pages/contact.astro
  • packages/starpod/src/pages/for-llms.astro
  • packages/starpod/src/pages/index.astro
  • packages/starpod/src/styles/episode.css
  • packages/starpod/src/styles/explorer.css
  • packages/starpod/src/styles/global.css
  • packages/starpod/src/styles/people.css
  • packages/starpod/src/styles/player.css
  • packages/starpod/src/styles/rail.css
  • packages/starpod/src/styles/shell.css
  • packages/starpod/src/styles/tokens.css
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

The reference site's sponsor page uses .ep-reveal and .ep-grow but does
not load episode.css, so splitting the page CSS left its cards and chart
bars without their scroll-driven entrance. They are general-purpose
reveal utilities, so they move to global.css with their keyframes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RobbieTheWagner
RobbieTheWagner merged commit 8bdf42d into media-redesign Nov 30, 2026
9 checks passed

This branch was successfully deployed

1 active deployment
Preview — 4fa57f06 Deployed Nov 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant