Skip to content

Conversation

erikhfj
Copy link
Member

@erikhfj erikhfj commented Nov 25, 2026

Closes #133

Stacked on #140 (feat/132-a11y-theme-and-ux-polish → #138 feat/131-client-routing-and-cache → main).

What was done

  • Optimized hero WebP assets (client/src/assets/vinyl-hero.webp, client/src/assets/vinyl-hero-mobile.webp, client/src/assets/vinyl-hero.LICENSE.md):
    • Before: vinyl-hero.webp (1800×2700 portrait) — 449,868 B (439.3 KB)
    • After (desktop): vinyl-hero.webp (1280×720 landscape, WebP q78) — 39,164 B (38.2 KB) (-91.3%, < 80 KB)
    • After (mobile): vinyl-hero-mobile.webp (640×360 landscape, WebP q75) — 13,394 B (13.1 KB) (-97.0%, < 35 KB)
  • Responsive high-priority hero & tighter mobile layout (client/src/pages/DiscoveryPage.tsx, client/src/App.css, client/src/components/SearchForm.css):
    • Replaced CSS ::before hero background with a decorative <picture> element (<source media="(max-width: 700px)" type="image/webp"> + <img srcSet="... 640w, ... 1280w" sizes="100vw" width={1280} height={720} alt="" aria-hidden="true" loading="eager" fetchPriority="high" decoding="async">).
    • Tightened mobile hero padding, heading/tagline scale, and margins, kept SearchForm single-row down to 22.5rem while preserving >= 2.75rem touch targets, and added a mobile "Browse catalog" jump link to #catalogue.
  • Referrer privacy (client/src/components/AlbumCover.tsx, client/index.html):
    • Added referrerPolicy="no-referrer" to external Cover Art Archive artwork <img> elements and <meta name="referrer" content="no-referrer" /> to client/index.html.
  • Apache 2.4 & VM hardening runbook (docs/VM-setup.md):

What was tested

  • pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm build — all passed with 0 lint warnings and clean client/src/generated.
  • Updated unit tests in client/src/App.test.tsx, client/src/components/AlbumCover.test.tsx, and client/src/pagination.test.tsx.
  • Verified JS bundle budget (<= 512,000 B): largest chunk index-BHPMzRCN.js is 393,206 B.
  • Verified built client/dist/index.html includes <meta name="referrer" content="no-referrer" /> and external /project2/theme-init.js (298 B) with zero inline scripts.

Copy link
Member

@evenkkl evenkkl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good PR. The hero is 91–97% smaller, and the Apache config is correct for 2.4. I only looked at what this PR changes on top of #140.

Looks good

  • NODE_ENV (from the #136 review): covered now. The runbook has the Environment=NODE_ENV=production drop-in, daemon-reload + restart, and systemctl show -p Environment crate-api to check it.
  • CSP matches what the app needs. I checked each part:
    • script-src 'self' works because theme-init.js is an external file, the Vite bundle is a module script and index.html has no inline scripts.
    • style-src 'self' works because Vite emits CSS as separate stylesheet files. The one inline style (visibility on the artwork credit in AlbumDetailPage) is set by React through element.style, and CSP doesn't block that.
    • img-src: the redirect chain for coverartarchive.org/release-group/…/front goes to archive.org and then ia*.us.archive.org. *.archive.org matches subdomains at any depth, so every hop is allowed.
    • font-src / data:: all fonts and both hero images are over Vite's 4 KB inline limit, so none of them becomes a data: URI. Self-hosted woff2 passes font-src 'self'.
    • connect-src 'self' works because the client falls back to the relative /graphql.
  • Apache 2.4:
    • Header set (not always) for Cache-Control means error responses don't get immutable.
    • FallbackResource and DirectoryIndex redirect internally to index.html, so deep links and a missing asset get no-cache (not immutable) and the CSP.
    • AddOutputFilterByType DEFLATE works on proxied responses in 2.4, and both of Yoga's JSON content types are listed.
  • Hero markup: alt="" + aria-hidden, width/height to avoid layout shift, and the image files really are 1280×720 and 640×360. fetchPriority="high" is fine here. aria-hidden doesn't remove an image from LCP, and the hero is the largest element above the fold, so it's most likely the LCP element.
  • License file: updated for both files. The Unsplash License allows crops, and the credit link is still visible.

Should fix (docs only)

  1. The runner note relies on a setting that isn't in this stack. It says to "rely on the workflow's read-only GITHUB_TOKEN permissions (contents: read)", but ci.yml on this branch has no permissions: block. That block comes from #134. Please write "after #134". It also claims more than the token can do. The token only limits the GitHub API. PR jobs run on the VM as the runner user, and that user can write /var/www/html/project2 and restart crate-api. If that's also the user that owns .env, PR code can read it even with chmod 600. I'd write "limits what the token can do on GitHub", not "cannot modify … deployment state".
  2. NODE_ENV does nothing until #129 is merged. Nothing in server/src on this stack reads NODE_ENV. The isProduction check is on fix/129-…. One line, "takes effect once #129 is merged", would prevent someone from thinking introspection is already off.

Non-blocking

  1. The 640w entry in srcSet is never used. Viewports ≤700px always take the source element, and above 700px sizes="100vw" always picks 1280w. Pick one: drop the source element and keep srcSet/sizes, or drop srcSet/sizes from the img. type="image/webp" on the source element does nothing either, since the fallback is also WebP.
  2. Mobile looks soft on high-DPR phones. The hero is close to square on phones, so object-fit: cover scales the 640×360 image up a lot. On a 3x phone it's roughly 3.5x. The overlay hides most of it. A portrait-ish mobile crop of about 750×900 would look sharper for a few more KB.
  3. The image is still found late. The img only exists after React renders, so the preload scanner can't see it. The biggest LCP gain here is the smaller file. If you want more, an image preload (rel="preload" as="image" with imagesrcset and media) in index.html would help, but it needs stable file names (for example in public/). A Lighthouse mobile before/after in the PR would show whether that's worth it.
  4. theme-init.js gets no Cache-Control. It isn't hashed, so browsers cache it by guessing from Last-Modified. Adding it to the no-cache <Files> (e.g. <FilesMatch "^(index\.html|theme-init\.js)$">) avoids an old copy after a deploy.
  5. Test the CSP in a browser before turning it on. The curl -I checks only show that the header is there. Loading Discover and an album page with DevTools open, or using Content-Security-Policy-Report-Only for one deploy, would catch anything I missed.

@erikhfj erikhfj force-pushed the feat/132-a11y-theme-and-ux-polish branch from f9925a6 to 87269e0 Compare November 26, 2026 19:37
@erikhfj
Copy link
Member Author

erikhfj commented Nov 26, 2026

Thanks for the careful review, @evenkkl! Rebased onto the updated #140 and addressed your review items in 629879b:

Verified locally with pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm build (all JS chunks <= 512 KB, zero inline scripts in dist/index.html).

@erikhfj erikhfj force-pushed the perf/133-hero-lcp-and-apache-headers branch from 03da34a to 629879b Compare November 26, 2026 19:40
Copy link
Member

@evenkkl evenkkl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, all of it checks out. Approving.

  • Runner note: now says plainly that contents: read only limits the token on GitHub, and that PR jobs run as the deploy user with access to .env, the web root and systemctl restart. Good. Note that #137 isn't merged yet, so the permissions: block isn't on main until it is.
  • NODE_ENV: the "supported since #129 / PR #136" note is correct. #136 is merged, and main has the isProduction check.
  • theme-init.js caching: the FilesMatch regex is right, the quoted heredoc keeps the backslashes, and the expected output now lists it.
  • CSP check: the DevTools / Report-Only note is what I was after.
  • Hero markup: the plain src + mobile source is correct now, and the tests check that srcset/sizes/type are gone.
  • Favicon: it's same-origin, so img-src 'self' covers it, and it removes the /favicon.ico 404.

The mobile crop and the image preload from last time are still open, but both were non-blocking. Fine as follow-ups if Lighthouse shows they matter.

…d-delivery

docs: #135 final documentation sync, AI reflection, Lighthouse/a11y log, and screenshots
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants