Find the Invisible Cost: a CSS Animation and a Shared Paint Layer
Two of the biggest wins in the lab came from code nobody suspected: two bouncing navigation arrows, and the order of layers inside one SVG. Day 8 shows the instruments that found them and why each fix changes nothing a child can see.
A forced recalculation in every frame
By this point, the remaining JS cost looked spread out. So web-trace.mjs gained a new lens: forced style and layout. It lists every style recalculation or layout that ran inside script (in a rAF callback or an event handler), grouped by the script that triggered it, with --stacks for the line of code.
forced style/layout (inside script), low-end playground drag:
334 ms 403x UpdateLayoutTree in FireAnimationFrame @ render
Almost every frame, the first layout read in render() (the one Day 3 deliberately moved to the start of the frame) was forcing a style recalculation. Something was invalidating style between frames.
Bisecting with CSS
Rather than guessing, the trace was rerun with CSS overrides injected into the page:
as is 294 ms forced
*{animation:none; transition:none} 2 ms
[data-zone-arrow]{animation:none} 17 ms
[data-zone-arrow]{will-change:transform} 276 ms
The culprits were the two ‹ › zone arrows, which bob gently to invite a child to the next area of the world: an infinite CSS keyframe animation. On this machine it ticked on the main thread and invalidated style before every frame, so the stage's first read paid for a whole style pass, and the browser then did another after the frame's writes.
The fix keeps the exact same motion: a 6 px bob every 1.8 s, now written from the stage's own frame loop, after the view's reads. Disabled arrows are not touched, and reduced-motion preferences still keep them still. A browser check sampled the arrow's position every frame for 3.6 s in both builds: amplitude 6 px vs 6 px, period 1 800 ms vs 1 800 ms, curves within 0.11 px.
One debugging detour is worth telling. The first browser check reported the new arrow not moving at all. The cause was the check, not the code: the test page left the stage below the fold, and the stage's clock pauses when the stage is off screen, so the bob paused too. With the stage in view the curves matched. Lesson: when a fix appears to break something, check the harness before the fix.
Before and after side by side
The zone arrows (EXP-031), low-end playground:

The underlay (EXP-033): before 43–58 fps with 22–24 % dropped; after 49–51 fps with 15–17 % dropped.

| low-end, interleaved, 2 runs | before | after |
|---|---|---|
| forced style recalc per drag trace | 334 / 333 ms | 10 / 15 ms |
| playground swipe, dropped | 76 / 81 % | 36 / 37 % |
| playground drag-slow, dropped | 49 / 43 % | 20 / 24 % |
| paint, playground drag (underlay) | 2.09 / 2.06 s | 1.09 / 1.06 s |
| paint, playground swipe (underlay) | 1.57 / 1.53 s | 0.72 / 0.71 s |
| bench dropped-frame sum (underlay, 24 cells × 2) | 639 | 462 (−28 %) |
Design principles at work
- Separate what changes from what doesn't. The underlay is the rendering version of the single-responsibility principle: one layer for the static world, one for what moves, so a change in one never forces work in the other.
- Single source of time. The arrows now take their time from the stage's frame loop like every other animation, so they pause with the stage, respect the same order of reads and writes, and cannot invalidate style behind its back.
- Prototype through the instrument.
--evaland--csslet an idea be measured in the real page before any product code is written.
Key takeaways
- Trace forced style and layout with stacks; the first read of a frame often pays for someone else's invalidation.
- Bisect with CSS overrides before touching code.
- Static and moving content should not share a paint layer; split them and prove pixel parity.
- When a fix seems to break something, suspect the measurement harness first.