Skip to content

10. The Rendering Pipeline — Frames, Jank and Why Things Feel Jerky

“Smoothness is not speed. Smoothness is keeping a promise, sixty times a second.”

In a cinema in the 1950s, a projectionist feeds a reel of film through a projector. The film is a strip of still photographs — frames — 24 every second. A shutter blinks between them so you never see the film move. Your brain, given a steady stream of slightly different stills, invents motion.

Now imagine the projectionist’s assistant has to paint each frame by hand, just before it goes through the gate. Most of the time she keeps up. But every so often a frame is complicated — a crowd scene, a sky full of birds — and she isn’t finished when the shutter opens. The projector does the only thing it can: it shows the previous frame again. The audience sees the motion hiccup. The film hasn’t slowed down overall; it’s the missed promise that you notice.

Or think of a flipbook. Flip it evenly and a stick figure runs smoothly. Stick two identical pages together and the figure freezes for an instant, then jumps. You’d notice that one stuck page far more than you’d notice the whole book being flipped a bit slower.

Your browser is that projectionist and that painter at once. The display refreshes on a fixed schedule — 60 times a second on most phones, 90 or 120 on newer ones. Each time, it shows whatever frame the browser has ready. If the browser hasn’t finished the next one, the display shows the old one again. That repeated frame is a dropped frame, and a run of them is jank.

This chapter is about everything the browser does to produce one frame, which parts happen where, and why some things — a route change, a blur, a height animation — make it miss its deadline.

A display refreshes at a fixed rate. Between refreshes there’s a deadline, signalled by VSync (vertical sync, the moment the display starts scanning out a new image). At:

  • 60 Hz, a new frame every 16.67 ms,
  • 90 Hz, every 11.1 ms,
  • 120 Hz, every 8.33 ms.

That’s the frame budget: the time the browser has to produce the next frame. But not all of it is yours. The browser has its own overhead (compositing, GPU work, IPC, input handling), so a realistic target for your JavaScript, style and layout on the main thread is roughly 10 ms per frame at 60 Hz — less at 120 Hz.

Here’s what most people get wrong: humans are more sensitive to inconsistency than to low frame rates. A steady 30 fps animation can look acceptable; a 60 fps animation that drops to 40 for three frames every second looks broken. What we perceive as “smooth” is frame pacing — each frame arriving on time, evenly. A stutter is a broken promise.

Also note: the browser doesn’t produce frames when nothing changes. A static page isn’t “running at 0 fps” in any bad sense; it’s idle. Frame rate only matters while something is moving or responding: scrolling, animating, reacting to input.

Try it: does this frame fit?

The arithmetic: at 60 Hz the browser has 16.67 ms between display refreshes, and realistically about 10–12 ms for your work after its own overhead. If JavaScript + style + layout + paint on the main thread exceed the budget, that frame misses its VSync and the previous frame is shown again: a dropped frame. On a 4× slower phone, 8 ms of work becomes 32 ms: two frames missed.

To turn HTML, CSS and JavaScript into pixels, the browser runs a pipeline. Chromium’s modern rendering architecture (often called RenderingNG) splits it into these stages. Other engines differ in names and details but have the same broad shape.

The rendering pipeline by threadStages in order across three lanes. Main thread: parse to DOM and CSSOM, style, layout, pre-paint (property trees), paint (display lists), then commit. Compositor thread: layerize, then activate and draw/composite, producing a compositor frame. Raster threads and GPU: raster tiles, then the GPU process aggregates and displays. Arrows run left to right.Main threadParseDOM/CSSOMStyleLayoutPre-paintprop. treesPaintdisp. listsCommitCompositorLayerizeActivateDrawframeRaster + GPURaster tilesAggregate+ display
Figure 10.1. The rendering pipeline. Stages on the main thread are expensive to repeat and blocked by your JavaScript; stages on the compositor, raster and GPU can keep running when the main thread is busy.

Let’s walk them, each with its job, its cost, and what makes it expensive.

The HTML parser builds the DOM (Chapter 9). CSS is parsed into style rules — the CSSOM. Both are data structures on the main thread. JavaScript can then modify either at any time.

For every element, the browser computes the final value of every CSS property: which rules match, which win by specificity and order, what inherits, what var() and calc() resolve to. Output: computed style per element.

Cost scales with number of elements whose style is invalidated × complexity of matching. Changing a class on <body> can invalidate styles for the entire document. Deep descendant selectors and :has() can make matching more expensive (engines optimize heavily, but a selector that forces broad re-matching on every change costs). DevTools shows this as purple “Recalculate Style” blocks with an element count — your first clue.

Given computed styles, compute the geometry: the position and size of every box. Text must be shaped and broken into lines; flexbox and grid algorithms run; percentages resolve against parents; images’ aspect ratios matter. Output: the layout tree (or “fragment tree”) with positions and sizes.

Layout is often the most expensive main-thread stage after JavaScript, and its cost scales with how much of the tree is dirty. Change the width of a container at the top of a 5,000-node page and the browser may re-lay-out everything inside it. Purple “Layout” blocks in DevTools, with a count of nodes needing layout.

Before painting, Chromium builds property trees: separate trees for transforms, clips, effects (opacity, filters, blend modes) and scroll offsets. Instead of every element carrying its own full transform matrix, they reference nodes in these trees. This is what lets the compositor later change a transform or opacity, or scroll, without redoing layout or paint: it just updates one node in a property tree.

“Paint” in the browser does not produce pixels. It records display lists: ordered drawing commands like “fill rect at (0,0,300,40) with #fff”, “draw text run ‘Monsoon’ at (12,28) with font X”, “draw image Y here.” Recording is relatively cheap; the expensive pixel work comes later. Green “Paint” blocks in DevTools.

Paint is invalidated when something’s appearance changes (colour, background, shadow, text) and also after any layout change that moves things.

The main thread hands the results — layout, property trees, display lists — over to the compositor thread. During commit, the main thread blocks briefly so the data can be copied consistently. After commit, the main thread is free to start on the next frame’s JavaScript while the compositor works on this one. This handoff is why the compositor can keep things moving when the main thread later gets stuck.

The compositor decides how to split the page into layers (Chromium calls them composited layers or, more precisely, groups of paint chunks into cc layers). A layer is a separately-rastered piece of the page that can be moved, faded or transformed independently by the GPU. Most pages need only a handful: the root, fixed headers, things with will-change: transform, videos, canvases, elements with active transform/opacity animations.

Rasterization turns display lists into actual pixels, in tiles (squares of the layer, e.g. 256×256 or larger), on raster worker threads. In modern Chromium this is usually GPU rasterization: the raster threads translate drawing commands into GPU commands (via Skia) that the GPU executes, writing pixels into textures. Only tiles that are visible or about to be visible are rastered first; tiles far off-screen may wait. When you scroll fast and see a checkerboard or blank areas briefly, that’s raster not keeping up.

Image decoding also happens around here: a JPEG/AVIF must be decoded into raw pixels before it can be drawn. Chromium decodes images on raster/decoder threads, not the main thread, in most cases. Large images are expensive to decode (a 4000×3000 photo is 48 MB of raw RGBA pixels).

Chromium keeps two copies of the layer tree on the compositor: the pending tree (receiving new rastered tiles from the latest commit) and the active tree (what’s currently being drawn). When enough of the pending tree is rastered, it’s activated — swapped in. This prevents half-rastered content from flashing on screen.

On each VSync, the compositor takes the active tree, applies the current scroll offsets and any compositor-driven animations (transform, opacity), and generates a compositor frame: a list of textured quads to draw. It sends that to the GPU process (“Viz” in Chromium), which aggregates frames from all sources (the page, cross-site iframes in other processes, the browser UI) and issues the final GPU draw calls.

The GPU writes the final image into a buffer; the OS compositor and display hardware scan it out at the next refresh. Pixels.

Stage Thread CPU or GPU
JavaScript Main CPU
Parse HTML/CSS Main CPU
Style Main CPU
Layout Main CPU
Pre-paint, Paint (record) Main CPU
Commit Main → Compositor CPU
Layerize, Activate, Draw Compositor CPU (small)
Image decode Decode/raster threads CPU
Raster Raster threads Mostly GPU (via GPU process); CPU if GPU raster is unavailable
Composite / display GPU process GPU

Two immediate consequences:

  1. The main thread does almost all the expensive, variable work: JS, style, layout, paint. It’s one thread, shared with every event handler, timer and framework.
  2. The GPU does the pixel work. When the GPU is weak, blocklisted, or busy with expensive effects (big blurs, many layers, huge textures), it becomes the bottleneck even when the main thread is idle. This will matter enormously in Chapter 16’s audit.

Here’s the heart of “why does this animation stutter and that one doesn’t?”

When you change a property, the browser restarts the pipeline from the earliest stage that property affects:

  • Change width, height, top, left, margin, padding, font-size, or add/remove elements → geometry changes → Style → Layout → Paint → Composite. Main thread, every frame.
  • Change color, background-color, box-shadow, border-radius (appearance only) → Style → Paint → Composite. Skips layout, still main thread.
  • Change transform or opacity on an element that has its own layer → Composite only. The compositor updates a property-tree node and redraws. The main thread isn’t involved, per frame.

So a CSS animation or transition of transform or opacity (and, in Chromium, some filter cases) can be run entirely by the compositor. It keeps going at full frame rate even when the main thread is blocked by a 500 ms task. An animation of left or height needs the main thread every single frame; when the main thread is blocked, it freezes, then jumps.

Which stages a property change triggersThree rows across five stage columns: JS, Style, Layout, Paint, Composite. Width, height, top, left: all five stages lit. Color, background, shadow: JS, Style, Paint and Composite lit, Layout skipped. Transform and opacity: only Composite lit, labelled compositor thread.JSStyleLayoutPaintCompositewidth, height, top, leftcolor, background, shadowtransform, opacitycompositor onlymain thread work per frame →
Figure 10.2. Three property families, three restart points. Geometry changes redo layout and everything after; appearance changes redo paint; transform/opacity only recomposite — and can run off the main thread entirely.

Try it: the cook vs the sous-chef

Main-thread frame rate: —

What you'd see: with the main thread blocked, the top ball (animating left) freezes and teleports roughly ten times a second, because every frame of it needs style, layout and paint on the main thread. The bottom ball (animating transform with a CSS animation) keeps gliding, because Chromium, Safari and Firefox run it on the compositor. The page's own frame-rate counter collapses either way: the main thread really is stuck.

Layers, promotion, will-change — and layer explosion

Section titled “Layers, promotion, will-change — and layer explosion”

For the compositor to move something independently, it must be on its own layer. Browsers promote elements automatically in many cases (an active transform animation, a video, a canvas, position: fixed in some situations). You can hint with will-change: transform (or opacity), which says: “I’m about to animate this; prepare a layer now so the first frame isn’t janky.”

Layers aren’t free. Each one:

  • needs its own texture memory on the GPU: width × height × 4 bytes (RGBA). A full-screen layer on a 1080×2400 phone is ~10 MB. Ten of them is 100 MB of GPU memory on a device that might have 4 GB total RAM shared between CPU and GPU.
  • adds compositing work each frame (more quads to draw, more overdraw).
  • can trigger implicit promotion: if element B overlaps a composited layer A and is above it in paint order, B must also get a layer to be drawn correctly (“overlap” promotion). Promote one element carelessly and dozens of siblings follow.

That runaway is layer explosion. Its symptoms: high GPU memory, slow compositing, and on low-end devices, tabs being killed. Its cause is usually will-change sprayed across many elements “for performance,” or transform: translateZ(0) hacks copied from 2014 blog posts.

Use will-change surgically: on the few elements about to animate, ideally added just before the animation and removed after. Check the Layers panel to see what you’ve actually got.

Layer promotion and explosionLeft: a page with a single root layer plus one promoted card for animation; GPU memory small. Right: the same page with will-change on every card, plus overlap promotion forcing more layers; dozens of textures and large GPU memory, shown in red.Surgicalroot layeranimating2 layers · ~12 MB GPUwill-change everywhere30+ layers (incl. overlap) · 100+ MB GPU
Figure 10.3. Layer promotion and its cost. A promoted element gets its own GPU texture, which is great for animation and costs memory. Overlapping siblings can be forced onto layers too — the start of a layer explosion.

Why navigations feel jerky — the core question

Section titled “Why navigations feel jerky — the core question”

You click a link in an SPA. The current page freezes for a moment, the exit animation stutters, then the new page pops in, then an image arrives and everything jumps, then the font swaps and the text reflows. What, precisely, happened? And does all of it “take CPU”?

Let’s take the anatomy apart, cost by cost. For each: what it is, which resource it consumes (network wait, main-thread CPU, other CPU threads, or GPU), and how it shows up.

Janky vs smooth route change timelineTwo scenarios, each with network, main, compositor and frames lanes over about 900 milliseconds. Janky: click, then network wait for chunk and data, then a long main-thread block of parse, compile, React render and commit, style and layout, during which the height-based exit animation freezes and frames are dropped, then image arrives causing a layout shift and a font swap causing reflow. Smooth: chunk and data were prefetched on hover, the click starts a transform-based view transition on the compositor, the main thread does render in small yielded chunks, every frame is delivered, and the new page appears complete with reserved image space.JankyclickNetworkchunk + data waitimage, fontMainheight animparse/compileReact renderlayoutshift + reflowFrames~13 dropped framesSmoothclickNetworkprefetched on hoverMainsmall yielded chunksCompositorview transition (transform/opacity)Framesevery VSync gets a frame
Figure 10.4. A janky SPA route change vs. a smooth one, by thread. Top: the exit animation uses height (main thread) and competes with chunk parsing, React render and a big layout — frames drop, then the new page arrives in pieces. Bottom: data and chunk prefetched, transform-based transition on the compositor, work split and yielded — every VSync gets a frame.

The new route needs data (/api/essays/monsoon) and maybe a JS chunk not yet downloaded. On Priya’s connection that’s a few hundred ms. Resource: pure waiting. The CPU is mostly idle. The user sees… whatever you show: a frozen old page (no feedback — feels broken), a blank screen (feels slow), or a skeleton/progress indicator (feels responsive).

Fixes: prefetch on hover/visibility; cache data client-side; show immediate feedback (pressed state, a progress bar) within 100 ms; keep the old page interactive while loading.

2. JS download → parse → compile → execute

Section titled “2. JS download → parse → compile → execute”

When the chunk arrives, V8 must parse it, compile it to bytecode, and execute its top-level code (Chapter 11). For a 200 KB chunk on a mid-range phone, that’s tens to hundreds of milliseconds. Resource: main-thread CPU (V8 can parse/compile some scripts on background threads, but module evaluation and execution are on the main thread). In DevTools: yellow “Compile Script,” “Evaluate Script.”

Fixes: smaller route chunks; prefetch and prime them early; avoid heavy top-level work in modules.

3. Framework work: render, reconcile, commit, effects

Section titled “3. Framework work: render, reconcile, commit, effects”

React (or any framework) runs your new route’s components (render), diffs against the old tree (reconcile), applies DOM mutations (commit), and runs effects (useEffect, useLayoutEffect). On first load, it hydrates instead (Chapter 7). Resource: main-thread CPU, often as one long task. Big component trees, expensive render logic, and synchronous state cascades multiply it.

Fixes: render less (virtualize, defer below-the-fold sections); memoize expensive subtrees; use transitions (startTransition) so React can yield; split work; move non-UI computation off-thread.

4. Style recalc and layout of a whole new page

Section titled “4. Style recalc and layout of a whole new page”

The commit replaced most of the DOM. Now the browser must compute style for every new element and lay out the entire page. Resource: main-thread CPU. Cost scales with DOM size and CSS complexity. A route with 6,000 nodes may need 30–100 ms of style + layout on a mid-range phone.

Fixes: smaller DOMs; content-visibility: auto for off-screen sections; simpler selectors; avoid layout-triggering reads in effects (see layout thrashing below).

5. Paint and raster of new content; image decode

Section titled “5. Paint and raster of new content; image decode”

Paint (recording) on the main thread, then raster on raster threads/GPU, then compositing on the GPU. New large images must be decoded — usually on decoder threads, but if the image needs to be ready synchronously for the frame, the frame may wait for decode. Resource: CPU (paint, decode) + GPU (raster, composite). decoding="async" lets the browser present the frame without waiting for an image’s decode; img.decode() lets you wait for decode before inserting the image, so it appears in one frame without a hitch.

If the new route uses a font not yet loaded, the browser either hides text until it loads (FOIT, flash of invisible text) or shows a fallback and swaps (FOUT). The swap changes glyph metrics, so text re-wraps: re-layout and repaint, and possibly a layout shift. Resource: network wait, then main-thread CPU.

Fixes: preload critical fonts; font-display: swap or optional; metric-matched fallbacks (size-adjust, ascent-override) so the swap doesn’t move anything (Chapter 18).

7. Layout shifts from late-arriving content

Section titled “7. Layout shifts from late-arriving content”

An image without dimensions, an ad, an embed, a “you might also like” block that loads after the main content — each pushes content down when it arrives. Resource: main-thread layout + paint each time, plus a terrible user experience (and CLS, Chapter 16). Fix: reserve space (width/height attributes, aspect-ratio, min-heights for async slots).

The old route’s components, data and DOM nodes become garbage. V8’s GC reclaims them; most of it happens concurrently on helper threads, but some phases pause the main thread briefly. Allocation-heavy navigations (parsing big JSON, creating thousands of objects) cause more GC. Resource: main-thread CPU (pauses) + helper threads. In DevTools: “Minor GC” / “Major GC” blocks.

9. Scroll restoration and focus management

Section titled “9. Scroll restoration and focus management”

In an MPA, the browser restores scroll on Back and moves focus to the new document automatically. In an SPA, you must: scroll to top on new routes, restore position on Back (after content has rendered — restoring too early lands in the wrong place), and move focus to the new page’s heading so keyboard and screen-reader users know something happened (Chapter 15). Done wrong, the page visibly jumps after rendering, or focus is lost on a removed element.

10. Long tasks block input — and that’s INP

Section titled “10. Long tasks block input — and that’s INP”

Any main-thread task over 50 ms is a long task. During a long task, the browser can’t run event handlers or produce frames (for main-thread-dependent content). If the user taps during your 400 ms route render, the tap waits. That waiting is measured by INP (Chapter 16): input delay + processing + presentation delay. A janky navigation is very often an INP problem in disguise.

Cost Network wait Main-thread CPU Other CPU threads GPU
Fetch data/chunk ✔ (network service)
Parse/compile/execute JS ✔ some background compile
React render/commit/effects ✔
Style + layout ✔
Paint (record) ✔
Raster ✔ (raster threads) ✔
Image decode sometimes ✔
Composite/display (compositor, small) ✔
Font load + swap ✔ ✔ (relayout)
GC ✔ (pauses) ✔ (concurrent)

The typical janky SPA navigation is dominated by main-thread CPU, with a network wait in front. That’s good news: it means it’s fixable in your code.

MPA vs. SPA feel, bfcache, prerendering, View Transitions

Section titled “MPA vs. SPA feel, bfcache, prerendering, View Transitions”

An MPA navigation hands most of this to the browser, which is very good at it: streaming parse, paint holding (keeping the old page visible until the new one can paint, avoiding a white flash), bfcache for instant Back, and prerendering via Speculation Rules — if the next page was prerendered on hover, the “navigation” is just swapping in an already-rendered page. Zero main-thread work at click time.

What MPAs historically lacked was transitions. The View Transitions API fixes that, for both models:

  • Same-document (SPAs): call document.startViewTransition(() => updateTheDOM()). The browser snapshots the old state, runs your update, snapshots the new state, and animates between them — by default a cross-fade, customizable with CSS (::view-transition-old(), ::view-transition-new()), and elements given a shared view-transition-name morph between their old and new positions. The animation runs on snapshots, as transform/opacity animations on the compositor.
  • Cross-document (MPAs): opt in with CSS (@view-transition { navigation: auto; }) on both pages, and same-origin navigations animate between full page loads.

The trick that makes View Transitions feel good is the same trick as everything in this chapter: the expensive DOM work happens while the browser holds a snapshot on screen, and the motion itself is compositor-friendly. But note: the transition can’t start until your DOM update callback finishes. A 400 ms render still delays the transition by 400 ms. View Transitions make a fast navigation beautiful; they don’t make a slow one fast.

Layout thrashing (forced synchronous layout)

Section titled “Layout thrashing (forced synchronous layout)”

Normally the browser is lazy in a good way: you change styles, it marks things dirty, and computes style/layout once, at the end of the frame. But if you read a layout property (offsetWidth, getBoundingClientRect(), scrollTop…) after writing something that invalidated layout, the browser must compute layout right now, synchronously, to give you a correct answer. That’s a forced synchronous layout. Do it in a loop — write, read, write, read — and you force a full layout on every iteration: layout thrashing.

// ❌ thrash: every iteration writes then reads → N layouts
for (const card of cards) {
card.style.height = `${card.parentElement.offsetWidth / 2}px`; // read after previous write
}
// ✅ batch: all reads, then all writes → 1 layout (later, at the frame)
const widths = cards.map((c) => c.parentElement.offsetWidth);
cards.forEach((c, i) => (c.style.height = `${widths[i] / 2}px`));

Try it: forced synchronous layout, measured on your machine

400 bars. Each run resizes every bar to its parent's width × a random factor.

Typical result on a laptop: interleaved takes tens to hundreds of milliseconds because every read of offsetWidth after a write forces the browser to run layout again, 400 times. Batched takes a millisecond or two: one layout for all the reads, one for all the writes at the next frame. Throttle the CPU 4× in DevTools and both numbers grow, but the ratio stays brutal.

In DevTools, forced layouts show as purple Layout blocks inside your JavaScript call stack, flagged with a warning (“Forced reflow is a likely performance bottleneck”).

Properties and methods that force layout (a non-exhaustive list worth memorizing in spirit): offsetTop/Left/Width/Height, clientTop/Left/Width/Height, scrollTop/Left/Width/Height, getBoundingClientRect(), getClientRects(), getComputedStyle() (for layout-dependent values), innerText, focus() (may scroll), scrollIntoView(), window.innerWidth/innerHeight, window.scrollX/Y, elementFromPoint().

Fixes: batch reads before writes; cache measurements; use ResizeObserver and IntersectionObserver (which deliver geometry asynchronously without forcing layout); schedule writes in requestAnimationFrame and reads after (or use a small read/write scheduler).

Layout thrashing timelineTop row: alternating small yellow script blocks and purple forced layout blocks, repeated many times, making a long task. Bottom row: one yellow block of reads, one of writes, then a single purple layout at frame time — much shorter.Thrash… × N = long taskBatchedreadswrites1 layout
Figure 10.5. Layout thrashing vs. batching on the main thread. Interleaving writes and reads forces a layout per iteration; batching lets the browser do one.

Containment, content-visibility, virtualization, DOM budgets

Section titled “Containment, content-visibility, virtualization, DOM budgets”

If style and layout scale with the size of the DOM, the cheapest fix is to make the browser look at less of it.

  • contain: layout paint style (or contain: strict/content) tells the browser an element’s insides don’t affect the outside. Changes inside it can’t trigger layout of the whole page; painting is clipped. It narrows the blast radius of updates.
  • content-visibility: auto goes further: the browser skips style, layout and paint entirely for the element’s contents while it’s off-screen, doing the work only as it approaches the viewport. On long pages (articles, feeds, documentation) this can cut initial rendering work dramatically. Pair it with contain-intrinsic-size (a placeholder size) so the scrollbar and layout don’t jump as sections render.
  • Virtualization (windowing) renders only the rows of a long list that are visible, plus a small buffer, recycling DOM nodes as you scroll. A 10,000-row table becomes ~40 rows of DOM. Essential for dashboards. Trade-offs: find-in-page and accessibility need care, and variable-height rows are tricky.
  • DOM size budgets. Lighthouse flags pages over roughly 1,400 elements. That’s not a hard rule, but it’s a good sanity number: every node costs memory, style and layout time, and slows every query. Large DOMs also make every React re-render more expensive.

Expensive effects: blur, filter, shadows, and glass

Section titled “Expensive effects: blur, filter, shadows, and glass”

Some CSS effects are cheap to declare and very expensive to draw.

  • filter: blur() and especially backdrop-filter: blur(): a Gaussian blur samples many neighbouring pixels for each output pixel. Implemented on the GPU in multiple passes, often with offscreen buffers (render the content into a temporary texture, blur horizontally, blur vertically, composite). Cost grows with the blurred area and with the blur radius. backdrop-filter is worse: it must read whatever is behind the element, which means the content behind must be rendered first into a texture, every frame that it changes.
  • Animated or scrolling content under a blur means the blur must be re-computed every frame. A static glass panel over a static background is cheap after the first frame; a glass panel over a moving wallpaper or video is a per-frame GPU cost.
  • SVG filters (feTurbulence, feDisplacementMap, feGaussianBlur chains — exactly what “lens” and “refraction” effects use) can be even heavier. Depending on the browser and filter, some SVG filter work may fall back to CPU rasterization, and changing their inputs can invalidate paint on the main thread.
  • Large, soft box-shadows are blurs too; animating them repaints each frame.
  • Many semi-transparent layers stacked increase overdraw: the GPU writes the same screen pixels multiple times per frame.

This is precisely why the author’s glass UI kit — lens filters, wallpaper canvas, glass surfaces — is beautiful and expensive. In Chapter 16 we’ll see a page with 108 glass surfaces and 106 lens filters across 18 iframes running at 41 FPS, and you’ll be able to explain every frame it drops: per-frame re-blur of moving content, offscreen passes per filter, overdraw, and many separate documents each running their own pipeline.

Try it: glass is expensive


FPS: —

What you'd see: with the background moving, every glass pane must re-read the pixels behind it, blur them (a multi-pass filter whose cost grows with the radius), and composite the result, every frame. On a laptop GPU a handful of panes is free; at 30–40 panes with a 40px+ radius, integrated GPUs and mid-range phones start missing frames. Freeze the background and the cost mostly disappears, because nothing behind the glass changed. Chapter 16 uses exactly this effect to explain the author's 41 FPS gallery.

Theory becomes skill when you can read a trace. Here’s a guided tour. Open DevTools → Performance, set CPU throttling to 4× or 6× (to approximate a mid-range phone; better, profile a real phone — Chapter 17), click record, perform the interaction, stop.

Performance panel anatomyA schematic of the Chrome Performance panel. Top: overview strip with CPU chart coloured yellow, purple and green, plus a red bar marking long tasks. Below: a Frames track with green good frames, red dropped frames and yellow partially presented frames. Then Interactions track showing a tap. Then the Main track: a flame chart with a wide yellow task marked with a red corner triangle, containing a call stack of functions, and nested purple Recalculate Style and Layout, and green Paint. Then compositor, raster thread and GPU tracks with small green blocks.Overview (CPU)long tasksFramesdroppedpartialInteractionspointer tap · INP 310 msMainTaskEvent: clickhandleNav()render()Recalculate Style · LayoutPaintCompositorRasterGPU
Figure 10.6. Anatomy of a Performance recording (schematic). Read top to bottom: overview → frames → main thread flame chart → compositor/raster/GPU tracks. Red triangles mark long tasks; red/yellow frames are dropped or partial.

1. The overview strip (top). A CPU chart over time, coloured by category. A red bar above it marks long tasks. A wall of yellow means JavaScript; purple means style/layout; green means paint. Drag to zoom into the interesting region.

2. Frames track. Each frame the browser intended to produce, with its duration. In current Chrome DevTools you’ll see good frames, dropped frames (no new content when one was expected), and partially presented frames (some content — say, a compositor-driven scroll — updated, but main-thread content didn’t make it). A run of dropped frames during an animation is jank you can point at.

3. Interactions track. Each user interaction (click, tap, keypress) with its duration; long ones are flagged. Hover to see input delay, processing time and presentation delay — the three parts of INP.

4. Main track (the flame chart). Time runs left to right; call stacks grow downward. Each top-level bar is a task. A task with a red triangle in its corner is a long task (>50 ms); the part beyond 50 ms is hatched in red. Click a bar to see its details at the bottom: self time, total time, the source location. Read a flame chart by finding the wide bars — width is time — and descending to see what inside them is wide.

Colours, consistently:

  • Yellow — Scripting: evaluate script, function calls, event handlers, timers, microtasks, GC (GC sometimes shown separately).
  • Purple — Rendering: Recalculate Style, Layout, pre-paint, layerize.
  • Green — Painting: Paint, and on other tracks, raster and composite work.
  • Grey — System/other: browser work not attributed to the page.
  • Blue — Loading/parsing HTML in some views.

5. Compositor, raster and GPU tracks. Here you see whether the GPU side is the bottleneck: long raster tasks during a scroll, or GPU busy for most of each frame with a heavy blur.

6. Insights and summary. Recent Chrome versions add an insights sidebar that highlights LCP breakdowns, layout shift culprits, forced reflows and long interactions, linking straight to the relevant part of the trace. Use it as a guide, not a verdict.

Open the command menu (Cmd/Ctrl+Shift+P) → “Show Rendering.” Toggles worth knowing:

  • Paint flashing — green flashes wherever the browser repaints. If a whole panel flashes on every frame of a small animation, something is invalidating too much paint.
  • Layout shift regions — blue flashes where content shifted (CLS culprits).
  • Layer borders — outlines of composited layers and tiles. A page covered in borders is a layer explosion.
  • Frame rendering stats (FPS meter) — a live overlay of frame rate and GPU memory.
  • Emulate CSS media features — prefers-reduced-motion, prefers-color-scheme, and more.

The Layers panel (More tools → Layers) shows a 3D view of the layer tree, each layer’s size, memory estimate, and the compositing reason (“has a will-change: transform”, “overlaps other composited content”). This is how you find out why you have 80 layers.

DevTools CPU throttling slows the main thread by inserting delays; it approximates a slower CPU but doesn’t model a weaker GPU, less memory, thermal throttling, or a slower storage/decoder. Use it to find main-thread problems, and confirm on real hardware (Chapter 17).

The infinite-scroll feed that got slower the longer you scrolled. A common pattern: an Instagram-style feed appends posts forever. By post 300 the DOM has 40,000 nodes, every “like” re-renders the list, and each new batch triggers style and layout over everything above it. Scroll was smooth (the compositor), taps were not (the main thread). Fix: virtualization and content-visibility, plus keyed, memoized list items.

The will-change cargo cult. A team adds will-change: transform to every card “for smoothness.” On low-RAM Android devices the tab begins crashing on long pages. The Layers panel shows hundreds of layers and hundreds of MB of GPU memory. Fix: remove it everywhere; add it only to the element being animated, only during animation.

The glass dashboard. A dashboard with frosted-glass panels over an animated gradient background runs at 60 fps on designers’ MacBooks and at 20–30 fps on the sales team’s Windows laptops with integrated GPUs, and worse in remote desktop sessions where GPU acceleration is disabled. Nothing in the main-thread profile is wrong; the GPU is drowning in per-frame blurs. Fix: freeze the background behind glass, reduce blur radius and area, cap live blur surfaces, and provide a solid fallback when GPU acceleration is unavailable.

You can explain what a frame is and why pacing matters more than raw FPS; name every stage of the pipeline, which thread runs it and whether it’s CPU or GPU; explain why transform/opacity survive a busy main thread and height/left don’t; manage layers without exploding them; break any janky navigation into network wait, JS cost, framework work, style/layout, paint/raster/decode, fonts, shifts, GC, scroll/focus and long tasks — and say which consume CPU, GPU or nothing; fix layout thrashing; use containment, content-visibility and virtualization; explain why blur and glass are expensive; and read a Performance trace from overview to flame chart to GPU track.

You now know more about the compositor than most people who use will-change.

1. What’s the frame budget at 120 Hz, and roughly how much of it is yours?

8.33 ms; realistically ~5–6 ms for main-thread work after browser overhead.

2. Why can a transform animation keep running during a 500 ms long task?

The compositor thread can update the transform in its property tree and draw frames without the main thread.

3. What does “Paint” in DevTools actually measure?

Recording display lists (drawing commands) on the main thread — not producing pixels, which is raster.

4. Why does reading offsetHeight after setting a style cost so much in a loop?

The read forces a synchronous layout to return an up-to-date value; doing it each iteration forces N layouts.

5. What does content-visibility: auto skip for off-screen content?

Style, layout and paint of the element’s contents until it nears the viewport.

6. Why is backdrop-filter: blur() over a video expensive every frame?

The content behind changes each frame, so the backdrop must be re-captured and re-blurred (multi-pass, offscreen) every frame on the GPU.

7. Can a View Transition hide a slow 400 ms render?

No; the transition starts after the update callback completes. It beautifies fast navigations, it doesn’t speed slow ones.

8. What does a red triangle on a task mean?

It’s a long task (over 50 ms); the excess is hatched red.

Warm-up 1. Classify the property. For each, which stages does an animation trigger: opacity, background-color, margin-left, transform: scale(), box-shadow, clip-path?

Solution

opacity, transform: composite only. background-color, box-shadow: paint + composite. margin-left: layout + paint + composite. clip-path: generally paint (some engines can composite certain clip-path animations, but don’t count on it).

Warm-up 2. Read the trace. A trace shows a 320 ms yellow task with “Evaluate Script” at the top, a 90 ms purple “Layout” inside a function called measureCards, and dropped frames throughout. What are the two problems?

Solution

A large script evaluation (too much JS on the route) and forced synchronous layout inside measureCards (layout thrashing). Split/defer the script; batch measurements.

Warm-up 3. CPU or GPU? A page scrolls at 30 fps; the main thread is idle; the GPU track is busy throughout. What’s likely happening?

Solution

GPU-bound: expensive compositing — large blurs/backdrop-filters, too many layers, big textures, overdraw. Check Layers and the Rendering tab.

Warm-up 4. Why the stutter? An accordion animates height from 0 to auto via JS. It’s smooth on a laptop, choppy on a phone during data loading. Explain.

Solution

Height animation needs layout every frame on the main thread; on the phone, data processing occupies the main thread, so frames are missed. Animate transform/clip or use a FLIP technique (Chapter 19), and yield during data work.

Lab 5. Lumen’s route change, profiled. Record a navigation from Lumen’s gallery to an essay with 4× CPU throttling (production build). Annotate the trace: network wait, script evaluation, render, style/layout, paint, image decode, font swap.

Expected outcome

A labelled screenshot of your own trace mapping to Figure 10.4. Most of the time should be main-thread CPU after a network wait.

Lab 6. Fix the route change. Apply: prefetch on hover, a transform-based transition (or View Transitions), reserved image dimensions, font-display + preloaded font, and splitting the render with startTransition. Re-profile.

Expected outcome

Fewer dropped frames, no layout shifts after arrival, the click responds within one or two frames.

Lab 7. Hunt a thrash. Add a “masonry” layout to Lumen’s gallery that measures each image’s height in a loop. Profile it, find the forced reflow warning, and fix it with batching or ResizeObserver.

Hint

The forced reflow appears as purple Layout inside your function’s stack with a warning icon.

Lab 8. Long page, cheap page. Make Lumen’s longest essay page 10× longer. Measure initial style + layout time. Add content-visibility: auto with contain-intrinsic-size to each section and measure again.

Expected outcome

Initial rendering work drops substantially; scrolling remains smooth; the scrollbar doesn’t jump if the intrinsic size is reasonable.

Lab 9. Layer audit. Open Lumen in the Layers panel. List each layer’s compositing reason and memory. Remove any unjustified promotion.

Expected outcome

A small number of layers, each with an explainable reason.

Staff 10. The design review sentence. Write the two-minute explanation you’d give in a design review for: “The route transition janks because the new chunk is parsed on the main thread right when we start the exit animation, and that animation uses height, so it can’t run on the compositor.” Include the fix plan.

Model answer

Explain the main thread as a single cook; show the trace; the height animation needs layout each frame, so it competes with chunk evaluation and React render; fix by (1) prefetching the chunk on hover so evaluation happens before the click, (2) switching the animation to transform/opacity or View Transitions so it runs on the compositor, (3) splitting the render with transitions so the main thread yields. Promise a before/after trace and INP numbers.

Staff 11. An effects budget. Propose an “effects budget” for a design system that uses glass/blur: limits, measurement method, fallbacks.

Model outline

Max live backdrop-filter surfaces per viewport; max blur radius; no moving content behind glass by default; measurement on a reference mid-range Android and an integrated-GPU laptop at 60 fps; fallback to solid translucent fills when GPU acceleration is unavailable, on weak devices (Chapter 17 detection), and under reduced transparency/motion preferences.