Common Causes of Layout Shift
You'll learn to identify the primary culprits that cause unwanted layout shifts and harm your CLS score.
Layout shift happens when visible elements suddenly move on screen, creating a jarring user experience. Now that you understand what CLS measures, let's pinpoint the most common causes so you can fix them.
Images Without Dimensions
When you don't specify width and height attributes on images, the browser doesn't know how much space to reserve while the image loads. It initially renders zero height, then jumps the content down when the image finally arrives.
Think of it like saving a seat at a theater. Without dimensions, the browser doesn't reserve any seats—everyone crowds in, then has to scramble when the image shows up late demanding space.
Dynamic Content Injection
Content that appears after the initial render—like ads, banners, cookie notices, or late-loaded components—pushes existing content down or sideways. This is especially problematic when these elements don't have reserved space.
Loading a third-party ad widget without a placeholder is a classic CLS offender.
Web Fonts (FOIT and FOUT)
Web fonts cause shifts in two ways:
- FOIT (Flash of Invisible Text): Text is invisible while the font loads, then suddenly appears, potentially changing layout
- FOUT (Flash of Unstyled Text): A fallback font displays first, then swaps to your web font with different metrics, shifting surrounding content
The size difference between Arial and your custom font can push entire paragraphs around when the swap happens.
Other Common Culprits
Animations that don't use transform properties, embeds without dimensions (videos, iframes), and dynamically injected CSS that changes element sizes all contribute to poor CLS.
Key Takeaway: The three biggest CLS culprits are unsized images, dynamically injected content without reserved space, and web font swapping—all preventable with proper dimension specification and space reservation.