Repository navigation
perf(build): inline critical css and trim the entry bundle - #656
Merged
Merged
Conversation
The 114 KB entry stylesheet was the only CSS file and blocked the first paint until it arrived. Nuxt's own inlineStyles option, set to true, writes it into the HTML instead; compressed, the page grows by about 17 KB. A budget test holds the blocking CSS below 4 KB.
posthog-js made up two thirds of the entry chunk. A replacement for the nuxt-posthog client plugin queues calls and loads the library on idle time after mount, then replays them in order. Feature flags still bootstrap from the server payload.
TheMeinerLP
force-pushed
the
perf/critical-render-path
branch
from
November 23, 2026 10:37
56641f5 to
7a769cf
Compare
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
launchpad | 7a769cf | Commit Preview URL Branch Preview URL |
Nov 23 2026, 10:42 AM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On a phone the home page appeared late. Two things stood in the way of the first paint: the page waited for a render-blocking stylesheet request, and the entry script was almost 480 KB, two thirds of it the analytics library, which every visitor downloaded and parsed before the page became interactive.
This change inlines the global stylesheet into the HTML, so no request blocks the first paint, and loads the analytics library after hydration, so it no longer sits in the entry bundle.
Changes
perf(build): inline the global stylesheet into the page—features.inlineStyles: true, withtests/performance/critical-css.spec.ts.perf(build): load posthog-js after hydration— a client plugin replaces nuxt-posthog's one. Calls made before the library arrives are queued and replayed in order, so the production-host opt-out and stored consent still run before any capture. Feature flags still bootstrap from the server payload, soblog-ethanol-conversionresolves as before. Budget test for the entry chunk (reads.output, skipped without a build).Measurements
Production build under
wrangler dev, Lighthouse 12.8.2, default mobile throttling, medians. Base isorigin/main(n=5), after is this branch (n=10), runs interleaved on one machine. Desktop is n=3.Entry chunk: 478,484 B -> 136,400 B raw, 139,226 B -> 42,808 B brotli. The HTML grows by the inlined stylesheet, about 17 KB brotli per page, inside the 25 KB budget. Machine load stayed below 12 except for some /en runs (up to 16), where the base's minimum was a 53 outlier.
Tried and dropped
modulepreloadto the entry chunks (first commit of this branch, removed): measured n=10 against the same build without it, Performance dropped on /en/blog 78 -> 72 and /de/events 87 -> 80 while /en rose 86 -> 92 and /de was flat (77 -> 76). That breaks the rule of no page losing more than 2 points, so the commit and its test are gone.@sourceand lazy seasons CSS: each under 3 KB brotli, skipped.Verification
pnpm test(2178 passed),pnpm quality(no rise; TypeScript errors still at the baseline 3),pnpm build.node scripts/cache-check.mjsandpnpm seo:check -- --base http://localhost:8787 --no-mockagainst the production build: no errors.