You start reading an article, your eyes settle on a sentence, and suddenly the whole page jumps down because a banner loaded above it. Or you reach for a button and tap an advert instead because the layout moved at the last moment. That experience has a name: layout shift. Google measures it with Cumulative Layout Shift (CLS), one of the three Core Web Vitals. The good news is that CLS is usually the most approachable Core Web Vital to fix. Most shifts come from a small set of causes, and WordPress already gives you many of the tools you need. This WordPress CLS optimization guide shows you how to measure CLS, find the exact element that moves, and apply fixes that keep every template stable.

What Is Cumulative Layout Shift?
CLS measures how much visible content moves unexpectedly while a page is open. Each individual shift gets a score based on two things: how much of the viewport was affected and how far the content moved. A small icon nudging a few pixels barely registers, while a large block of text pushed halfway down the screen scores heavily. According to web.dev’s CLS documentation, the thresholds are:
| CLS rating | Score |
|---|---|
| Good | 0.1 or less |
| Needs improvement | Above 0.1 up to 0.25 |
| Poor | Above 0.25 |
As with the other Core Web Vitals, the goal is to reach a good score for at least 75% of page visits, measured from real users. If you have already worked through our LCP optimization guide and INP optimization guide, CLS completes the set.
How CLS is calculated over time
CLS is not simply a sum of every shift from the moment a page opens until the visitor leaves. Shifts are grouped into session windows. A window collects shifts that happen in quick succession (less than one second apart) and is capped at five seconds. The page’s CLS is the score of the worst window. This approach is fair to long-lived pages: a single article that stays open for twenty minutes is not penalised for small, isolated movements spread across the visit.
Expected shifts do not count
Not all movement is bad. When a visitor clicks an accordion and it expands, that layout change is expected. Shifts that happen within 500 milliseconds of a discrete user input, such as a click, tap or key press, are excluded from CLS. Scrolling does not count as that kind of input, so content that jumps while someone scrolls will still be measured. This is an important detail for lazy-loaded sections, which we will come back to later.
Why CLS Matters for Your WordPress Site
Visual stability is about trust. When a page holds still, visitors read comfortably, tap the button they intended to tap and feel that the site is well built. Core Web Vitals are also part of Google’s page experience signals, so keeping CLS in the good range supports your search visibility alongside great content. Above all, a stable layout is simply a better experience on mobile, where screens are small and a shift of a few hundred pixels can move content completely out of view.
How to Measure CLS on WordPress
Good CLS work starts with measurement. You need two kinds of data: field data that shows what real visitors experience, and lab data that helps you reproduce and diagnose a shift.
Field data: what real visitors see
- PageSpeed Insights shows Chrome User Experience Report (CrUX) data for a URL and for your whole origin when enough traffic exists. Open PageSpeed Insights and look at the CLS value in the “Discover what your real users are experiencing” section.
- Google Search Console groups URLs with similar issues in its Core Web Vitals report, which makes it easy to see whether a whole template (for example every single post) has a CLS issue.
- Site Kit by Google can show PageSpeed Insights data inside your WordPress dashboard, which is convenient for regular check-ins.
Field data has a delay of up to 28 days because CrUX reports a rolling window. After you deploy a fix, give it a few weeks before judging the result.
Lab data: finding the element that moves
Field data tells you that a page shifts. Lab tools tell you what shifts and why:
- Lighthouse (in Chrome DevTools or PageSpeed Insights) lists the largest layout shifts and the elements involved, often with a likely cause such as an unsized image or a web font.
- The Chrome DevTools Performance panel records a page load and shows a Layout shifts track. Click any shift to highlight the element that moved. The live metrics view shows CLS updating in real time as you interact with the page.
- Layout Shift Regions in DevTools (under the Rendering tab) briefly flashes a coloured overlay on areas that shift, which makes jumps obvious while you scroll.
Always test with a throttled mobile profile and in a private window. Cookie notices, consent banners and returning-visitor states behave differently when you are logged in, so testing as a first-time visitor gives you the most realistic view.
Measuring with the web-vitals library
For a deeper picture, the open-source web-vitals JavaScript library reports CLS from real visits and its attribution build tells you which element caused the largest shift. Many analytics tools build on it. A minimal example looks like this:
import { onCLS } from 'web-vitals/attribution';
onCLS( ( metric ) => {
console.log( 'CLS:', metric.value );
console.log( 'Largest shift target:', metric.attribution.largestShiftTarget );
} );
Sending these values to your analytics lets you see which templates and which elements shift most often for real visitors.
The Most Common Causes of Layout Shift
According to web.dev’s guide to optimizing CLS, most poor CLS scores come from a handful of familiar patterns:
- Images without dimensions. The browser does not know how much space to reserve, so content jumps when the image arrives.
- Ads, embeds and iframes without reserved space. Video players, maps, social embeds and ad slots often load late and push content down.
- Dynamically injected content. Banners, notices, related-post widgets or “subscribe” bars inserted above existing content.
- Web fonts. When a custom font replaces a fallback font with different measurements, every line of text can reflow.
- Animations that change layout. Animating
height,width,topormarginmoves neighbouring elements.
Let us take each one in turn and look at the WordPress-friendly fix.

Step-by-Step WordPress CLS Optimization
1. Give every image width and height
When an img element carries width and height attributes, modern browsers calculate an aspect ratio and reserve the right amount of space before the file downloads, even when CSS makes the image responsive. WordPress helps here: since WordPress 5.5, core automatically adds missing width and height attributes to images inserted in post content, as long as the image is from your media library.
Where shifts still appear, they usually come from images added outside post content:
- Theme templates that output
<img>tags by hand. Usewp_get_attachment_image()orthe_post_thumbnail()instead, because they output dimensions,srcsetandsizesfor you. - Page builder modules or sliders where the image size is set by CSS only. Check the module’s settings for a fixed height or aspect ratio option.
- Images loaded from external URLs that WordPress cannot measure. Add the dimensions yourself or wrap the image in a container with a fixed aspect ratio.
A safe CSS pattern for responsive images that keeps the reserved space is:
img {
max-width: 100%;
height: auto;
}
The height: auto rule lets the browser use the aspect ratio from the attributes. Avoid setting a fixed pixel height on responsive images unless you also use object-fit.
2. Reserve space for embeds, videos and iframes
Embeds are a frequent source of shifts because their final size is only known after a third-party script runs. WordPress block themes and many classic themes declare support for responsive-embeds. With that support, the Embed block adds aspect-ratio classes such as wp-embed-aspect-16-9 and wp-has-aspect-ratio, so a YouTube video reserves a 16:9 box before the player loads. If your theme is classic, you can opt in:
add_action( 'after_setup_theme', function () {
add_theme_support( 'responsive-embeds' );
} );
For iframes that are not handled by the Embed block, such as a booking widget or a map, use the CSS aspect-ratio property or a min-height that matches the widget’s usual size:
.booking-widget iframe {
width: 100%;
aspect-ratio: 4 / 3;
}
3. Reserve space for ads and promotional slots
Ads often load after the main content and can be different sizes. The most reliable approach is to give each ad slot a container with a min-height that matches the most common ad size for that position. If no ad fills the slot, a short, tidy placeholder is a much better experience than a sudden jump. Place ad slots between content blocks rather than at the very top of the page where any change affects everything below it.
4. Position notices and banners so they do not push content
Cookie consent notices, announcement bars and newsletter prompts are valuable, but they can shift the layout when they appear at the top of the page. Two patterns keep them stable:
- Overlay instead of insert. Use
position: fixedorposition: stickyso the banner floats over the page rather than pushing content down. - Render it from the start. If a bar must sit in the normal flow, output it in the initial HTML (with its final height) instead of injecting it with JavaScript after the page loads.
Test these elements in a private window, because they often only appear for first-time visitors.
5. Load web fonts without reflow
When a web font arrives and replaces the fallback font, text can change width and line height. On a long article, that reflow can move dozens of lines. There are three complementary fixes:
- Host fonts locally and preload the most important file. Fewer connections means the font arrives sooner, often before the first paint. The WordPress Font Library stores installed fonts on your own server, which helps.
- Choose a sensible
font-displayvalue.swapshows fallback text immediately and swaps later, which is good for readability but can cause a shift.optionalonly uses the web font if it is ready very quickly, which gives the most stable layout. - Match the fallback font’s metrics. The
size-adjust,ascent-overrideanddescent-overridedescriptors let you tune a local fallback font so it occupies almost exactly the same space as your web font.
@font-face {
font-family: 'Inter Fallback';
src: local('Arial');
size-adjust: 107%;
ascent-override: 90%;
}
body {
font-family: 'Inter', 'Inter Fallback', sans-serif;
}
The exact percentages depend on the font pairing, and free tools can calculate them for you. Even approximate values noticeably reduce text reflow.
6. Use transform for animations
Animating properties such as height, top or margin forces the browser to recalculate layout and move neighbouring elements. Animating transform and opacity does not affect surrounding layout, so it never contributes to CLS. For example, slide in a notice with transform: translateY() rather than animating its top value. This also makes animations smoother, which supports a good INP score.
7. Keep lazy-loaded sections stable
Infinite scroll, “load more” lists and lazy-loaded comment sections are helpful, but they can shift content when they expand during scrolling (remember, scrolling does not exclude shifts from CLS). Give lazy sections a placeholder with a realistic min-height, or load them only after a click, so the expansion follows a discrete user input. Native lazy loading of images is safe for CLS as long as the images have dimensions, because the space is reserved even before the file downloads.
8. Check headers, sliders and sticky elements
A header that changes height when it becomes sticky, a hero slider whose height depends on the first image, or a mega menu that renders late can all cause shifts above the fold. Give these components fixed or aspect-ratio-based heights, and make sure sticky header changes happen with transform or within a fixed-height wrapper.
9. Enable the back/forward cache
When visitors use the browser’s back and forward buttons, pages served from the back/forward cache (bfcache) are restored instantly, with no layout shifts at all. Pages are often excluded from bfcache because of Cache-Control: no-store headers or unload event listeners. Chrome DevTools has a Back/forward cache test in the Application panel that tells you whether a page is eligible and, if not, why. Pairing bfcache with speculative loading makes navigation feel both instant and stable.
WordPress-Specific CLS Checklist
Use this list as a quick review whenever you launch a new template or theme update:
| Area | What to check | Recommended fix |
|---|---|---|
| Post content images | Width and height attributes present | Insert images from the media library |
| Theme templates | Hand-written img tags | Use wp_get_attachment_image() |
| Embeds | Videos and social posts jump | Enable responsive-embeds support |
| Ads | Slots expand after load | Containers with min-height |
| Banners and notices | Content pushed down | Fixed positioning or server-rendered |
| Web fonts | Text reflows on swap | Local hosting, preload, metric-matched fallback |
| Animations | Neighbours move | Animate transform and opacity |
| Lazy sections | Shifts while scrolling | Placeholders or click-to-load |
Testing Your Fixes
After each change, repeat the same lab test so you compare like with like:
- Open the page in a private window with mobile throttling.
- Record a Performance profile and confirm the original shift is gone from the Layout shifts track.
- Scroll the full page with Layout Shift Regions enabled to catch shifts below the fold.
- Run Lighthouse to confirm the overall lab score.
- Wait for field data in PageSpeed Insights or Search Console to update over the following weeks.
If you manage several sites, it is worth adding CLS to a regular performance review alongside LCP and INP, because new plugins, ads or design changes can introduce shifts at any time.
Frequently Asked Questions
Can CLS be zero?
Yes. Many well-built pages have a CLS of 0 or very close to it. You do not need perfection, though: anything at or below 0.1 for most visits is considered good.
Does lazy loading images hurt CLS?
Not when images have width and height attributes. The browser reserves the space even before a lazy image downloads, so the image fills an existing box rather than pushing content.
Why does Lighthouse show good CLS while Search Console reports a problem?
Lighthouse measures a single page load without scrolling or interaction, while field data includes everything real visitors do, such as scrolling past lazy content or seeing a consent banner. Use field data as your guide and lab tools to reproduce what visitors experience.
Do caching plugins fix CLS?
Caching improves loading speed, which can reduce some font-related shifts, but CLS is mainly a layout question. Reserving space for content is what fixes it.
Conclusion
CLS rewards careful, thoughtful layout work. Give images and embeds their dimensions, reserve space for anything that loads late, position notices so they float rather than push, load fonts with matched fallbacks and animate with transforms. WordPress core already handles many of these details for content added through the editor, so most of your attention can go to theme templates and third-party elements. With these steps in place, your pages will feel calm, trustworthy and professional on every device, and your Core Web Vitals report will reflect it. For the full picture, continue with our guides to LCP and INP.

Leave a Reply