Performance as a product decision.
Fast pages are decided before the first component is written: what renders where, what ships, and what animates. Performance is not a cleanup phase.
- Published
- 09 Dec 2025
- Length
- 5 min read
- Roles
- Architecture, Frontend, Product
- From the work on
- Ema, CRED
Every slow page I have inherited was slow because of a decision made in a planning document. A hero that had to be a video. A pricing table that had to be live. A scroll animation that had to move the layout. Nobody wrote "make it slow", but by the time an engineer opened a profiler, the budget had already been spent.
So I stopped treating performance as a phase. It is a set of product decisions: what to render where, what to ship, what to animate. Make them early and most of the optimisation work never needs to happen.
Decide what renders where
The first question for any page is which parts can be known at build time. For a marketing site the honest answer is almost all of it. Headlines, layout, images, navigation, footer. The dynamic parts are small: a signed-in state, a price pulled from a billing system, a list of the latest posts.
The rendering strategy follows from that answer. Build the static shell ahead of time and serve it from the edge. Stream the dynamic pieces into that shell with Suspense boundaries, so the page is readable before the slow data arrives. Cache aggressively at each layer: immutable for hashed assets, stale-while-revalidate for semi-static HTML, no caching only for what is truly per-user.
At Ema the public web and docs are generated from a content snapshot in the repository, so there is no data fetch at request time at all. The Partner Portal sits behind authentication and renders per request, but its shell, navigation and layout are still static. Only the data is dynamic.
import { Suspense } from "react";
export const revalidate = 3600; // regenerate at most once an hour
export default function ProductPage() {
return (
<>
<Hero /> {/* static, in the build */}
<Features /> {/* static, in the build */}
<Suspense fallback={<PricingSkeleton />}>
<Pricing /> {/* async server component, streamed */}
</Suspense>
<Footer />
</>
);
}The product decision hiding here is "does this section need to be live?". Most of the time the answer is no, and a sentence in the brief that says "pricing updates within an hour" saves a round trip on every visit.
Decide what to ship
Images and fonts
Images are usually the largest thing on a page and the easiest to get wrong. The rules are boring and they work: modern formats, sized to the slot they fill, explicit dimensions so nothing shifts, lazy below the fold, and exactly one image marked as priority, the one that will be the Largest Contentful Paint.
Fonts are the second most common cause of layout shift. Self-host them, subset to the characters you use, preload only the weight used above the fold, and give the fallback font metric overrides so the swap does not move text.
@font-face {
font-family: "Brand Sans";
src: url("/fonts/brand-sans-latin.woff2") format("woff2");
font-weight: 400 700;
font-display: swap;
unicode-range: U+0000-00FF, U+2013-2014, U+2018-201A, U+201C-201E;
}
/* Metric-matched fallback so the swap does not reflow the page */
@font-face {
font-family: "Brand Sans Fallback";
src: local("Arial");
size-adjust: 106%;
ascent-override: 92%;
descent-override: 24%;
line-gap-override: 0%;
}
:root {
--font-sans: "Brand Sans", "Brand Sans Fallback", system-ui, sans-serif;
}Video, PNG sequences, or neither
Apple-style product pages, where a device rotates or assembles as you scroll, are where asset decisions matter most. At CRED I built a library for exactly this kind of page, and the core of it was a rule for choosing the medium per scene.
- PNG sequence when the user controls time. Scroll-scrubbing needs frame-accurate seeking, and video elements seek badly unless every frame is a keyframe. Sequences are heavy, so the library decoded frames into an offscreen canvas, loaded them progressively in scroll order, and served smaller frames to smaller viewports.
- Video when the scene plays once, linearly, and the user does not control it. Hardware decoding makes it the cheapest way to move a lot of pixels.
- DOM animation when the subject is UI: text, cards, buttons, lines. A transform on a real element is cheaper than any raster, and it stays crisp at every zoom level.
The question to ask in the design review is "who controls time in this scene?". The answer picks the medium, and the medium decides the weight.
Decide what to animate
Animation cost is decided by which properties move. transform and opacity can be handled entirely by the compositor. Anything that changes geometry, such as width, height, top, left or margin, forces layout and then paint on every frame, and on a long page that is the difference between smooth and stuttering.
The practical rules I hold to:
- Animate only
transformandopacity. If a design needs something else, change the design. - One ticker. GSAP's ticker is a single
requestAnimationFrameloop, so every scroll-linked effect runs in the same frame instead of fighting for it. - Read, then write. Measure every element once, up front, and again on resize. Never call
getBoundingClientRectinside the frame loop after you have started writing styles, because that forces a synchronous layout. will-changeis a request, not a decoration. Set it just before an element animates and clear it after. Leaving it on hundreds of elements eats GPU memory and makes the page slower, not faster.- Respect
prefers-reduced-motion. Scroll scrubs become static frames, parallax becomes a crossfade. The content is identical.
import gsap from "gsap";
const items = Array.from(document.querySelectorAll<HTMLElement>("[data-parallax]"));
let tops: number[] = [];
function measure() {
const y = window.scrollY;
tops = items.map((el) => el.getBoundingClientRect().top + y); // all reads, once
}
measure();
window.addEventListener("resize", measure, { passive: true });
gsap.ticker.add(() => {
const y = window.scrollY;
const mid = window.innerHeight / 2;
items.forEach((el, i) => {
const distance = tops[i] - y - mid;
gsap.set(el, { y: distance * -0.1 }); // all writes, transform only
});
});Measure, with targets you can fail
Targets have to be numbers or they are opinions. I use the Core Web Vitals thresholds as the floor: LCP at or under 2.5 seconds, INP at or under 200 milliseconds, CLS at or under 0.1, measured at the 75th percentile of real visits.
Lab data and field data answer different questions. Lighthouse and WebPageTest are reproducible, so they are for diagnosis and for catching regressions before merge. Field data, from the Chrome UX Report or a small web-vitals beacon, is what users actually experience and what search engines actually use. A page can score well in the lab and fail in the field on cheap phones over slow networks, so both are required.
Budgets belong in CI, where a regression becomes a failed check rather than a complaint a month later. INP cannot be measured in a lab run, so Total Blocking Time stands in for it.
{
"ci": {
"collect": {
"url": ["http://localhost:3000/", "http://localhost:3000/docs"],
"numberOfRuns": 3
},
"assert": {
"assertions": {
"largest-contentful-paint": ["error", { "maxNumericValue": 2500 }],
"cumulative-layout-shift": ["error", { "maxNumericValue": 0.1 }],
"total-blocking-time": ["warn", { "maxNumericValue": 200 }],
"resource-summary:script:size": ["error", { "maxNumericValue": 250000 }]
}
}
}
}What I'd carry forward
- Ask "does this need to be live?" and "who controls time in this scene?" in the design review, not in the profiler.
- Static shell first, stream what must be dynamic, cache everything else.
- Pick the medium per scene: sequence for scrubbing, video for linear playback, DOM for UI.
- Animate only
transformandopacity, in one ticker, reads before writes. - Put numeric budgets in CI and treat a failed budget as a failed build.