CLS Fixer: Stop Your Page From Jumping Around
You go to tap a button and the page jumps, so you hit an ad instead. That's layout shift, and it annoys users and hurts your Core Web Vitals. This prompt finds what moves on your pages, why it moves, and gives you simple code fixes to make every page stay still.
Example input
This is exactly what we gave the model. You replace it with your own details.
- Website: https://news.example.org (local news site) - Platform and theme: WordPress with a news theme and an ad network plugin - Page types with poor CLS and example URLs: Article pages, for example /2026/11/council-approves-new-bus-routes/ - CLS field data (CrUX or Search Console) for mobile and desktop: CLS p75: mobile 0.31, desktop 0.12 - Elements I see moving: Ads above and inside the article jump the text down; a cookie banner pushes the page down from the top; the headline font changes size after loading; an embedded social post grows after a second - Ads, embeds and late-loading widgets used: Header ad (728x90 desktop, 320x100 mobile), 2 in-article ad slots, a sticky video player, embedded social posts, a newsletter sign-up box that loads after 3 seconds
Real output
Pasted straight from the model. We did not fix a word.
Quick questions (I used my best guess for each and kept going)
- Which ad network and plugin do you use? Are the in-article slots added by a script after the page loads? Guess: Google Ad Manager-style tags (GPT) through the network's own WordPress plugin. Yes, the in-article slots are added by JavaScript.
- Which sizes can the in-article slots show on mobile? Is there an "Advertisement" label? Guess: 300x250 and 336x280, with a label about 20px tall.
- Which cookie tool do you use, and where does the banner sit? Guess: a WordPress cookie plugin set to a top bar that pushes the page down.
- Which headline font do you use, and how is it loaded?
Guess: a serif Google Font, loaded by the theme with
font-display: swap. - Where do the video player and the newsletter box show up? Guess: the player starts inside the article and floats to a bottom corner when you scroll past it. The newsletter box is added inside the article text by a script.
Where your score likely comes from
- Mobile 0.31 is Poor (over 0.25). Desktop 0.12 is Needs improvement. The goal is 0.1 or less at p75 on both.
- CLS is your worst burst, not the total of all shifts. On mobile, the worst burst is probably the first few seconds: the cookie banner, the header ad and the headline font all move the page at about the same time (guess). Fix these three together. If you fix only one, the score may barely change, because the other two still make a big burst.
- A second burst probably happens while people read: in-article ads, the video player, the newsletter box and social posts. Lab tools don't scroll, so they miss these. Your field data catches them. Scrolling does not count as user input, so these shifts count.
- Mobile is worse because the same push is a bigger share of a small screen. A 100px push on a screen about 750px tall moves all the visible text by about 13% of the screen height. Rough math for the header ad alone: impact fraction ~1.0 × distance fraction ~0.13 ≈ 0.13 (guess).
- Before you change code, run Step 0 of the Verify plan (section 4) to confirm each culprit. Rows 1, 3 and 4 are safe to ship right away.
1. Table (ranked by impact, highest first)
| Element | Why it shifts | Fix | Code | Impact |
|---|---|---|---|---|
| 1. Header ad (320x100 mobile, 728x90 desktop) | The slot starts at 0px tall. When the ad arrives (often 1–3 s after load), it opens to 100px or 90px and pushes the logo, headline and text down. This can happen again if the ad refreshes to a different size. | Reserve the height before the ad loads. Use one height per screen size, matching the ad network's size mapping, and add the label height. Don't collapse the slot when it's empty. | Block 1: .ad-slot--header { min-height: calc(100px + var(--ad-label)); } | High. Every page view, above the fold. Guess: ~0.1–0.13 on mobile, and most of desktop's 0.12. |
| 2. In-article ad slots (2) | The slot is added (or filled) while the reader scrolls. A 300x250 ad pushes the text down by about 270px, which is about a third of a phone screen. | Put both slot containers in the page HTML at fixed paragraph positions. Reserve the height of the tallest size you allow. Keep lazy loading on. With the space reserved, it no longer moves anything. | Block 1: .ad-slot--inarticle { min-height: calc(280px + var(--ad-label)); } | High on mobile. Guess: 0.1–0.2 when one shift lands on screen. Lab tools usually miss it. |
| 3. Cookie banner | It is added at the top of the page, in the normal page flow, after load. Or the plugin adds top padding to <body>. Either way, the whole page moves down. | Make it an overlay: position: fixed at the bottom, sliding in with transform. A new fixed element doesn't move anything else, so it doesn't count. | Block 2: position: fixed; bottom: 0; | High for first-time visitors. Guess: 0.05–0.15 on mobile, in the same burst as the header ad. |
| 4. Headline font | The headline shows in a fallback font first. Then the web font swaps in with different letter widths and line height. On mobile, a long headline can go from 3 lines to 4 and push everything below it. | Preload the one headline font file, self-host it, and add a size-adjusted fallback font so both fonts take up the same space. Option: font-display: optional for the headline only. | Block 3: @font-face { font-family: "Headline Fallback"; src: local("Georgia"); size-adjust: …; } | Medium. Guess: 0.02–0.06 on mobile, part of the first burst. |
| 5. Sticky video player | Guess: the player box is added to the article with no height. When it floats on scroll, its space in the article closes and the text jumps up. If the float animation changes top, bottom, width or height, the player itself also counts as moving. | Reserve a 16:9 box in the article that keeps its height when the player floats. Float the player with position: fixed and animate it with transform. | Block 5: .video-slot { aspect-ratio: 16 / 9; } | Medium (guess). Hits every reader who scrolls past it. |
| 6. Newsletter box (after 3 s) | A script adds it to the page 3 seconds after load and pushes the content below it down. 3 s is far past the half-second grace period after a tap or click, so it counts. | Reserve its space in the HTML at its final spot, or show it as a bottom slide-in overlay, or add it only when its spot is below the screen. Keep the 3 s delay. | Block 6: .newsletter-slot { min-height: 320px; } | Medium (guess). High if it lands above the line the reader is on. |
| 7. Embedded social posts | WordPress prints a short quote first. About a second later, the platform's script swaps in a much taller iframe (often 400–700px) and pushes the text below it down. | Reserve a min-height on the embed wrapper for each platform. Let the embed script load before the reader reaches the post. | Block 4: .is-provider-twitter .wp-block-embed__wrapper { min-height: 500px; } | Low to medium. Only articles with embeds, but high on those if the post is near the top. |
2. Code blocks
To see where each block goes, read step 1 of the Platform steps (section 3). Class names marked "placeholder" must be changed to the real class names you see in DevTools.
Block 1: Reserved space for the header ad and in-article ads (rows 1 and 2)
The HTML must come from the server as part of the page. A script must not add it later.
<!-- Header ad: in the theme header, above the logo/menu -->
<div class="ad-slot ad-slot--header" id="ad-header"></div>
<!-- In-article ads: printed after paragraphs 3 and 8 (guess) by the plugin's placement -->
<div class="ad-slot ad-slot--inarticle" id="ad-inarticle-1"></div>
<div class="ad-slot ad-slot--inarticle" id="ad-inarticle-2"></div>
:root {
--ad-label: 20px; /* guess: height of your "Advertisement" label. Use 0px if there is none. */
}
.ad-slot {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin: 16px auto; /* adjust to your theme's spacing */
background: #f4f4f4; /* an empty slot looks planned, not broken */
}
/* Header, mobile: 320x100. Reserve the tallest size this slot can show. */
.ad-slot--header {
min-height: calc(100px + var(--ad-label));
}
/* Header, desktop: 728x90. Use the SAME breakpoint as the ad network's size mapping. */
@media (min-width: 768px) {
.ad-slot--header {
min-height: calc(90px + var(--ad-label));
}
}
/* In-article: guess 300x250 and 336x280, so reserve 280px. */
.ad-slot--inarticle {
min-height: calc(280px + var(--ad-label));
}
Your network may use Google Publisher Tags (GPT), and the plugin may let you edit the tag code. If so, stop these slots from collapsing:
// Remove this line if it is in your ad code. It closes empty slots, which moves the page:
// googletag.pubads().collapseEmptyDivs();
// Or turn it off only for these slots (headerSlot = the slot returned by googletag.defineSlot):
headerSlot.setCollapseEmptyDiv(false);
Block 2: Cookie banner as an overlay (row 3)
/* Placeholder selector: change .cookie-banner to your plugin's banner class or ID. */
.cookie-banner {
position: fixed !important;
top: auto !important;
left: 0;
right: 0;
bottom: 0;
z-index: 100000; /* above the floating video player and the newsletter popup */
animation: slide-up 0.3s ease-out;
}
/* Shared animation, also used in Blocks 5 and 6.
It moves things with transform only, and transform changes are not layout shifts. */
@keyframes slide-up {
from { transform: translateY(100%); }
to { transform: translateY(0); }
}
/* Only needed if the plugin adds space at the top of the page when the banner shows.
Placeholder class: check in DevTools which class or inline style the plugin adds to <body>. */
body.cookie-banner-active {
padding-top: 0 !important;
margin-top: 0 !important;
}
Block 3: Headline font with a size-matched fallback (row 4)
<!-- In <head>, early. Preload only the one file the headline uses. -->
<link rel="preload" href="/wp-content/themes/your-child-theme/fonts/headline-700.woff2"
as="font" type="font/woff2" crossorigin>
/* 1. The web font, self-hosted (placeholder name and path) */
@font-face {
font-family: "Headline";
src: url("/wp-content/themes/your-child-theme/fonts/headline-700.woff2") format("woff2");
font-weight: 700;
font-style: normal;
font-display: swap; /* or: optional (see the notes below) */
}
/* 2. A local fallback font, sized to take the same space.
The four numbers are PLACEHOLDERS. Get the real ones for your font from a tool
such as Fontaine or Capsize, or an online "fallback font generator". */
@font-face {
font-family: "Headline Fallback";
src: local("Georgia"); /* use local("Arial") if your headline font is sans-serif */
size-adjust: 105%;
ascent-override: 90%;
descent-override: 24%;
line-gap-override: 0%;
}
/* 3. Use both fonts on the headline (change .entry-title to your theme's headline class) */
.entry-title {
font-family: "Headline", "Headline Fallback", Georgia, serif;
}
Notes:
font-display: optionalon the headline removes the swap completely. If the font isn't ready in about 100ms, that visit keeps the fallback font. With the preload, most visits still get the web font. Use this if the size-matched fallback still leaves a small shift.- Search the theme CSS for rules like
.wf-active .entry-title { font-size: … }or.fonts-loaded h1 { … }. Rules like these change the size after the font loads. Make the size the same before and after. - CrUX field data comes from Chrome, and Chrome supports all four fallback settings above.
Block 4: Reserved space for social embeds (row 7)
/* WordPress embed blocks. The heights are guesses for mobile:
measure 3–4 of your real embeds in DevTools and adjust them. */
.wp-block-embed.is-provider-twitter .wp-block-embed__wrapper { min-height: 500px; }
.wp-block-embed.is-provider-instagram .wp-block-embed__wrapper { min-height: 650px; }
.wp-block-embed.is-provider-facebook .wp-block-embed__wrapper { min-height: 500px; }
/* Short text-only posts: editors add the class "embed-short" to the block */
.wp-block-embed.embed-short .wp-block-embed__wrapper { min-height: 250px; }
If an embed comes from a plugin and not from the core Embed block, use that plugin's wrapper class instead.
Block 5: Video player that keeps its space when it floats (row 5)
<div class="video-slot">
<div class="video-player"><!-- the vendor's player loads here --></div>
</div>
/* The box in the article. It has its height before the player loads, and it keeps it. */
.video-slot {
width: 100%;
max-width: 640px;
aspect-ratio: 16 / 9;
margin: 16px auto;
background: #000;
}
.video-player {
width: 100%;
height: 100%;
}
/* Floating mode (placeholder class). Only the player leaves; .video-slot stays the same size. */
.video-player.is-floating {
position: fixed;
right: 12px;
bottom: 12px;
width: min(300px, 60vw);
height: auto;
aspect-ratio: 16 / 9;
z-index: 9000;
animation: slide-up 0.25s ease-out; /* transform only, from Block 2 */
}
Block 6: Newsletter box without a jump (row 6)
Option A (best): reserve its spot in the HTML.
<!-- Printed by the theme at the box's final spot (guess: after paragraph 6) -->
<div id="newsletter-slot" class="newsletter-slot"></div>
.newsletter-slot { min-height: 320px; } /* guess: the box's real height on mobile */
@media (min-width: 768px) {
.newsletter-slot { min-height: 220px; } /* guess: the box's real height on desktop */
}
Then point the 3-second script at #newsletter-slot, so it fills that box and doesn't add a new one.
Option B: add the box inside the article only if its spot is below the screen. Otherwise, show it as an overlay.
setTimeout(() => {
const box = buildNewsletterBox(); // your existing code that makes the box
const spot = document.querySelector('.entry-content > p:nth-of-type(6)'); // placeholder spot
if (spot && spot.getBoundingClientRect().top > window.innerHeight) {
spot.after(box); // the spot is below the screen, so nothing the reader sees moves
} else {
box.classList.add('newsletter-popup');
document.body.appendChild(box); // shown as an overlay instead
}
}, 3000);
.newsletter-popup {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 99999; /* below the cookie banner */
animation: slide-up 0.3s ease-out; /* from Block 2 */
}
If the cookie banner is still open, wait until it closes before you show the popup, so the two don't stack.
3. Platform steps (WordPress)
Step 1: Where to put the code
- CSS: in your child theme's
style.css, or in Appearance > Customize > Additional CSS. On a block theme, use Appearance > Editor > Styles > Additional CSS. - Font preload: in the child theme's
functions.php, or in a code snippets plugin:
add_action( 'wp_head', function () {
echo '<link rel="preload" href="' . esc_url( get_stylesheet_directory_uri() . '/fonts/headline-700.woff2' ) . '" as="font" type="font/woff2" crossorigin>';
}, 1 );
- After each change, clear every cache: your caching plugin, your host and your CDN.
Step 2: News theme settings
- Header ad area: if the theme has a "Header ad" or "Header banner" field, keep using it. In DevTools, find the outer wrapper around it, meaning the element that is already in the HTML before the ad loads. Put the Block 1 header CSS on that wrapper's class.
- Turn off any "hide/collapse ad area when empty" option for the header and in-article areas.
- Typography: if the theme has a "load Google Fonts locally" or "self-host fonts" option, turn it on. If it doesn't, a plugin such as OMGF can self-host Google Fonts. Load only the font weights you use.
- If the theme loads fonts with a script (Web Font Loader), check for the
.wf-activesize rules described in Block 3.
Step 3: Ad network plugin
- In-article placement: switch from automatic/JavaScript insertion to fixed placements, such as "after paragraph 3" and "after paragraph 8" (guess), that print the container in the HTML. If the network only supports automatic insertion, ask support to put the ads into your own
divIDs from Block 1. - Look for a "reserve space", "placeholder height" or "CLS" setting, and set it to the heights in Block 1. If the plugin has no such setting, the CSS does the job.
- Turn off "collapse empty slots" for the header and in-article slots. When an impression goes unsold, show a house ad (for example, your newsletter promo) instead of collapsing the slot.
- Check which sizes each slot may show. A slot may be able to show a taller size, for example 300x600 in-article on mobile. If so, either reserve that height, or ask the network to serve that size only in a slot you have sized for it.
- Keep lazy loading on. With the space reserved, it no longer moves the text.
- Ask the network: "Do your ad containers change size after the ad renders?" If they do, ask the network to keep to fixed slot heights.
Step 4: Cookie plugin
- Set the position to "bottom bar" or "box/popup". Turn off options like "push page down", "static bar" or "top bar".
- If there is an animation setting, choose slide or fade (these use transform and opacity), not "expand".
- If your ads need a Google-certified consent tool (TCF), choose that tool's bottom or dialog format.
Step 5: Video player vendor (dashboard or support)
- Placement: inside the article, not above the headline.
- Turn on the option that keeps the in-article space when the player floats. The name varies between vendors, so ask support if you can't find it. Wrap the player in the
.video-slotbox from Block 5. - Floating position: a bottom corner on mobile, not a top bar that pushes the page down.
Step 6: Newsletter tool
- Keep the 3-second delay, but change the form type to "slide-in" or "fixed bottom bar". Most tools, such as MailPoet or OptinMonster, offer these. Or point the form at
#newsletter-slot(Block 6, option A). - Avoid a top bar that pushes the page down.
Step 7: Social embeds
- Use the core Embed block for X posts (guess: your embeds are X and Instagram). WordPress core no longer embeds Instagram or Facebook posts without a plugin. For those, use your plugin's wrapper class in Block 4.
- For short text-only posts, editors add
embed-shortunder Block > Advanced > Additional CSS class(es).
Step 8: Speed or caching plugin (guess: you use one, such as WP Rocket or LiteSpeed Cache)
- If "Delay JavaScript until user interaction" is on, exclude the embed scripts (
platform.twitter.com/widgets.jsand Instagram'sembed.js). Then the posts render before the reader reaches them. - If "Remove unused CSS" is on, add the classes that scripts add later to its safelist:
.is-floating,.newsletter-popup, and your cookie banner and ad classes. If you don't, the plugin may strip the new rules. - Make sure the CSS from Blocks 1–5 loads with your main CSS, not deferred.
4. Verify plan
Step 0: Baseline. Find each shift and its culprit (before any change)
- PageSpeed Insights (pagespeed.web.dev): test
https://news.example.org/2026/11/council-approves-new-bus-routes/on mobile and desktop.- In the top section ("Discover what your real users are experiencing"), note the CLS for "This URL" and for "Origin".
- In the lab section, open the layout shift diagnostic. Depending on the version, it is called "Avoid large layout shifts" or "Layout shift culprits". It lists the elements that moved and their likely causes.
- Remember that the lab test only loads the page. It doesn't scroll, and the ads may not fill. Expect it to miss rows 2, 5, 6 and 7.
- Chrome DevTools Performance panel (the most useful tool here):
- Open the article in an Incognito window. It has no extensions and no consent cookie, so the banner shows.
- In DevTools, turn on the device toolbar and pick a mid-size phone. In the Performance panel, set CPU to 4x slowdown and network to "Slow 4G".
- Click "Record and reload". After the page loads, scroll slowly to the end of the article, wait 5 seconds (for the newsletter box), then stop the recording.
- In the "Layout shifts" track, click each cluster (burst) to see its score. The highest cluster is your CLS for that visit. Click a single shift to see which elements moved and the likely root cause, such as a web font, an injected iframe or unsized media.
- The Performance panel's live metrics view also shows CLS updating as you scroll, with no recording needed.
- Layout Shift Regions: in DevTools, open ⋮ > More tools > Rendering and tick "Layout Shift Regions". Reload and scroll. Areas that move flash blue. This is good for showing your team.
- web-vitals library for real users. You need it for rows 2, 5, 6 and 7, which only happen when people scroll. Add it before
</head>(guess: GA4 is on the site via gtag):
<script type="module">
import { onCLS } from 'https://unpkg.com/web-vitals@5/dist/web-vitals.attribution.js?module';
onCLS(({ name, value, delta, id, rating, attribution }) => {
gtag('event', name, {
value: Math.round(delta * 1000),
metric_id: id,
metric_value: value,
metric_rating: rating, // good / needs-improvement / poor
debug_target: attribution.largestShiftTarget, // the element that moved the most
debug_time: Math.round(attribution.largestShiftTime || 0),
debug_load_state: attribution.loadState, // during load or after
});
});
</script>
- In GA4, register
debug_target,metric_ratinganddebug_load_stateas event-scoped custom dimensions. For production, installweb-vitalsfrom npm or host the file yourself. - An easy check: p75 ≤ 0.1 means at least 75% of page views have
metric_rating=good. - Like CrUX, this only measures Chrome and other Chromium-based browsers.
Step 1: Lab check after each change
Ship the fixes in ranked order, but ship rows 1, 3 and 4 together, because they make up the first burst. After each change:
- Clear all caches.
- Repeat the same DevTools recording: same phone, same throttling, same scroll path, same wait. Check that the shift for that element is gone from the "Layout shifts" track.
- Test these cases:
- Ad filled and ad empty. To get an empty slot, block the ad domain in DevTools > Network request blocking. The page should not move in either case.
- Cookie banner showing (Incognito), and after you click "Accept".
- Font not cached (tick "Disable cache") and font cached.
- An article with a social embed and an article without one.
- Phone width and desktop width.
- Run PageSpeed Insights on mobile 3 times and use the middle result. Aim for a lab CLS of 0.05 or less, which leaves room for real-world variation (guess at a safe margin).
- If you can, check on one real Android phone with
chrome://inspectremote debugging. Ads in an emulated phone can behave differently. - Write down the date of each change, so you can match it to the field trend later.
- For 2 weeks, watch ad fill, viewability and revenue in the network dashboard to make sure nothing dropped.
Step 2: Field data over 28 days
| When | Where | What to look for |
|---|---|---|
| Days 1–7 | Your web-vitals data in GA4 | The share of page views with "good" CLS rising toward 75%+ on mobile. Which debug_target values still show up most. |
| Days 7–28 | PageSpeed Insights field data (CrUX) | p75 CLS falling slowly. It is a rolling 28-day window, so old page views fade out gradually. |
| After the last fix | Search Console > Core Web Vitals | Open the mobile issue "CLS issue: more than 0.25" and click "Validate fix". Do the same for the desktop issue "CLS issue: more than 0.1". Validation runs for 28 days. |
| Day 28 | All three | Target: p75 of 0.1 or less on both mobile and desktop. If you're not there, take the top 2–3 debug_target values and repeat Step 0 for those elements. |
Expected result (guess): rows 1 and 3 alone should bring desktop under 0.1. Mobile needs rows 1–4, and row 2 matters most for readers who scroll.
Lines like “check: pass” or “fixed” are the model talking to itself. The prompt tells it to review its own work before answering; that review is part of the output.
The prompt
First lines open so you can see how it is built. The rest opens after purchase.
#ROLE You are a front-end performance expert specializing in Cumulative Layout Shift (CLS). Find what causes layout shifts on my pages and give me fixes. #INPUTS Fill in every line. Leave a line blank if you don't know it. - Website: [WEBSITE URL] - Platform and theme: [e.g., WordPress + ad network, Shopify theme, Next.js] - Page types with poor CLS and example URLs: [URLS]
How to use it
- Buy, then open it in your account.
- Copy the prompt into ChatGPT, Claude or Gemini.
- Replace the 6 inputs with your product.
- Run it. Use the output. Re-run with a different tone if you like.
Pro tips
- Reserve space for ads instead of removing them. A fixed min-height on each slot fixes most ad shifts.
- Show cookie banners as an overlay, not as a block that pushes the page down.
- Use the Layout Shift regions setting in DevTools to see exactly what moves.
Before you buy
- Will it work for my product?
- Yes, if you can fill the 6 inputs. If the output is bad with your inputs, email us: we fix the prompt and refund you.
- Do I download a file?
- No. It lives in your account with a copy button, and updates when we improve it.
- Which model is best?
- Best on Claude. Works in ChatGPT, Claude and Gemini.
Works well with this
Prompts people use in the same campaign.
More in Page Speed & Core Web Vitals
Buying more than two? Lifetime is cheaper.
Every prompt, every category, forever. $59 once. Nothing to download, nothing to renew.
This prompt
$3$7
- ✓ Instant access in your account, with a copy button
- ✓ Example input and real output included
- ✓ 7-day money-back, no form
Or get every prompt, forever
Lifetime Access · $59 $149 — all categories, all future prompts, rewrites included.
Get lifetime accessCard or PayPal · taxes at checkout · nothing to download
Not the one you need?
Browse every prompt by category and sub-category.