Critical CSS Strategy
Get the first screen styled correctly on the first paint, with no flash of raw markup.
What it adds
An inlined slice of the app's styles covering the first viewport, with the remainder loaded after paint.
What your agent is told to do
5
What your agent is told to do
5-
1
Identify the entry screens that are painted before the main stylesheet has arrived — the marketing page, the sign-in screen, the authenticated shell — and extract only the rules the first viewport actually uses on each.
-
2
Derive the critical slice from the same source as the full stylesheet, as a build step, so the two cannot drift apart when a component's styles change.
-
3
Resolve the user's theme, colour scheme, and any layout preference before the first paint, from a value that can be read synchronously at the top of the document rather than after the app boots.
-
4
Load the remainder without blocking rendering, and make sure the page reaches a fully styled state even if that request is slow — the inline slice is a head start, not a substitute.
-
5
Do not hand-write and hand-maintain a separate critical stylesheet. It goes stale the first time a component changes and nobody notices until a page renders wrong in production.
Edge cases it handles
7
Edge cases it handles
7- The extracted slice and the runtime stylesheet must agree on every rule they share. If a selector is inlined at one specificity and served at another, the page will visibly reflow the moment the full sheet applies.
- An inline payload that grows past a few kilobytes costs more than it saves, because it is re-sent with every document and cannot be cached separately. Set a budget and fail the build when it is exceeded.
- Theme has to be settled before anything paints. A dark-mode user who sees a white flash on every navigation is worse off than one who waited for the stylesheet.
- A strict content security policy will block inline styles outright unless they carry a nonce or hash. Confirm the delivery mechanism works under the policy the app actually ships, not a relaxed development one.
- Cached HTML holds the inline styles that were current when it was generated. After a deploy, a cached document paired with a new stylesheet must still render acceptably rather than half-styled.
- Print styles, reduced-motion rules, and high-contrast overrides are not first-viewport rules and must not be pulled into the inline slice.
- Font loading and font-face declarations belong to the Font Subsetting brief, not this one — keep the two from each inlining the same declarations twice.
Definition of done
8
Definition of done
8- Entry screens paint fully styled with no flash of unstyled or wrongly themed content.
- The critical slice is generated by the build from the same source as the full stylesheet.
- The inline payload has a documented size budget that the build enforces.
- The page reaches a complete styled state even when the deferred stylesheet is slow or fails once.
- Inline styles are delivered in a way the production content security policy permits.
- Theme and colour scheme are resolved before first paint on every entry point.
- The feature matches the existing design system.
- No existing functionality is broken.
Related features
Font Subsetting
Font Subsetting
Load only the glyphs a page needs, without breaking the alphabets it did not expect.
What it does
Per-script font subsets with declared character ranges and a fallback order for characters no subset covers.
How it works
- 1 Inventory the weights, styles, and families the app genuinely renders. Most projects ship two or three weights they never use, and dropping those is a larger win than any subsetting.
- 2 Split each family by writing system and declare the character ranges each file covers, so a page that renders only Latin text never fetches the Cyrillic or Greek file.
- 3 Choose subsets from the locales the product supports and the languages its users actually write in, not from the words currently on the page.
Copy the prompt
No account needed
Add this feature to my app:
https://addthisfeature.com/x/font-subsetting
Layout Shift Guard
Layout Shift Guard
Stop content jumping as a page loads, and catch it when it starts happening again.
What it does
Reserved space for everything that arrives late, plus measurement that reports unexpected movement on the app's main screens.
How it works
- 1 Walk the app's main screens with the network throttled and note everything that moves after first paint. Images, avatars, embeds, banners, ad slots, and asynchronously loaded panels are the usual sources.
- 2 Give every image, video, iframe, and embed explicit dimensions or a fixed aspect ratio so its box exists before its content arrives, including the ones whose size comes from data.
- 3 Control the swap from fallback to web font so the two have compatible metrics, and accept a slightly imperfect fallback over a page that reflows once the real font lands.
Copy the prompt
No account needed
Add this feature to my app:
https://addthisfeature.com/x/layout-shift-guard
Component Render Profiler
Component Render Profiler
Show which components re-render, what triggered it, and which of those actually cost anything.
What it does
A development-only instrument that records render counts, their causes, and their durations for the app's live screens.
How it works
- 1 Instrument the app's real screens rather than a test harness. Re-render problems come from the shape of actual data and actual state, and they do not reproduce on three sample rows.
- 2 Record for each render what changed to cause it, distinguishing a changed input, a state update in the component itself, and a shared value that changed above it.
- 3 Report duration alongside count, and sort by total time spent. A component that renders two hundred times cheaply matters less than one that renders four times and blocks the main thread each time.
Copy the prompt
No account needed
Add this feature to my app:
https://addthisfeature.com/x/component-render-profiler
How it works
-
1
Copy the link
Grab the Markdown instruction URL for this feature.
-
2
Give it to your AI
Paste it into Claude Code, Cursor, v0, Lovable — whatever you build with.
-
3
It inspects, then implements
Your agent reads your existing app first, then adds the feature to fit it.
Works with your stack
These instructions are written to adapt. They tell the agent to detect your framework, match your existing design system, and reuse what you already have — rather than assuming a particular stack.
Need it tighter than that? Customize the feature and tell it exactly what you're running.