🎨 CSS: Fix a Sticky Header Jittering During Momentum Scroll on iOS
A position: sticky header that looks rock-solid on desktop can visibly jitter or flicker during iOS Safari’s momentum scrolling, especially once a backdrop-filter blur is involved, because the browser’s compositor has to repaint that blurred layer on nearly every scroll frame instead of simply repositioning an already-composited layer — and momentum scrolling on iOS fires scroll position updates at a much higher effective rate than a normal drag, which is exactly the frame budget a per-frame repaint can’t keep up with.
🔎 The Problem
.site-header {
position: sticky;
top: 0;
backdrop-filter: blur(12px);
background: rgba(255, 255, 255, 0.7);
}
/* no explicit compositing hint - the browser decides on its own
whether this layer gets its own compositor layer or gets
repainted inline with the rest of the scrolling content */
âś… Fix: Give the Sticky Header Its Own Compositor Layer
- Add
transform: translateZ(0)orwill-change: transformto the sticky element to hint the browser into promoting it to its own compositor layer, so scrolling repositions an existing layer instead of repainting the blur on every frame. - Check every ancestor for
overflow: hiddenoroverflow: auto— a clipping ancestor between the sticky element and the scroll container can force extra layout/paint work during momentum scroll that a plain sticky element without one wouldn’t trigger. - If jitter persists specifically with
backdrop-filterapplied, test with the blur temporarily removed; if the jitter disappears, the blur’s per-frame repaint cost is the bottleneck, and a cheaper solid or gradient background may be the more reliable trade-off on iOS specifically.
🚨 Why This Is Dangerous
- Shipping a sticky header that tests perfectly smooth on every desktop browser and in the simulator, only to visibly stutter for real iPhone users during momentum scroll — a device-specific compositing cost that desktop dev tools and most simulators simply don’t reproduce.
Sticky positioning is cheap — repainting a blur underneath it on every scroll frame isn’t.
