Layout shift ate my click
19 October 2026 2 min read
A promo loads late and the button you were aiming at moves. Watch a tap land on the wrong thing, then fix it with one reserved box.
- Performance
- E-commerce
- Resilience
Cumulative Layout Shift sounds like a number for a dashboard. It is the moment you press Continue and the page rearranges itself under your thumb.
Promo is added when it arrives
Shifting page
Your order
- Ridge overshirt€189.00
- Shipping€0.00
Promo has a reserved slot
Stable page
Your order
- Ridge overshirt€189.00
- Shipping€0.00
Press "Load and tap Continue". Both pages are identical until a promo arrives after the delay you set. Then a tap lands exactly where Continue was a moment ago, the way a real thumb does when it is already on its way.
What happens on the left
The promo has no height until it arrives. When it does, the browser inserts it above the button and everything below moves down by the promo's height. The tap is still aimed at the old position, and whatever sits there now gets it.
Here that is "Add insurance". In a real checkout it could be a purchase, a subscription or a delete. Nobody reads a page that is still loading. They aim, and they trust that the page holds still.
What the right one does
It reserves the space. The slot is 64 pixels high from the first frame. The promo fills it when it arrives. Nothing around it moves, so there is nothing to mis-hit. The loading state is a quiet box of the same size, not a spinner somewhere else.
.promo-slot {
min-height: 64px; /* the promo's real height, not an estimate */
}
img {
aspect-ratio: 4 / 3; /* or width and height attributes, so the browser knows before the file arrives */
width: 100%;
height: auto;
}
The same bug in disguise
- Images without dimensions. The browser cannot reserve a space for a size it does not know.
widthandheightattributes, oraspect-ratio, fix it. - Web fonts that swap. A fallback font with different metrics reflows the text when the real one arrives.
size-adjustandfont-display: optionalkeep it quiet. - Banners that push. Cookie notices, promos and "new content" bars inserted above what the person is reading. Overlay them, or place them where nothing is being aimed at.
- Ads and embeds. Reserve the slot with the size you sell, even if the ad is smaller.
If you must insert above, ask first
When content arrives above the fold after someone started interacting, do not move anything. Show a small "3 new items" control and let the person decide. Feeds have done this for years for the same reason.
Measure it where it hurts
Lighthouse gives you a score. The browser also tells you each shift as it happens, and whether the person had just touched the screen.
new PerformanceObserver((list) => {
for (const e of list.getEntries() as any[]) {
if (!e.hadRecentInput) console.log('shift', e.value.toFixed(3), e.sources?.map((s: any) => s.node));
}
}).observe({ type: 'layout-shift', buffered: true });
Keep a slow network
Open DevTools, set the network to Slow 4G, and tap through the checkout as fast as you can. Every place where the page moves is a place where a real person pays for it. If the checkout only holds still on your office Wi-Fi, it is not finished.
Related
- Design the product card for the data you will actually get A card that works with the demo product breaks on the first real catalogue. Four toggles show where, and what a resilient card does instead.
- What 60 fps costs Part 2 of 3D on the web. Four knobs on one scene, a frame budget, and a live reading of what each knob costs on your device.