Ad code & integration

AdSense and Core Web Vitals: measuring the real impact of ads on LCP, INP and CLS

Last updated Published By the editorial team6 min6 sources

Key takeaways

  • Core Web Vitals pass at the 75th percentile of page loads when LCP is 2.5 seconds or less, INP is 200 milliseconds or less and CLS is 0.1 or less, for mobile and desktop separately.
  • Ads mostly affect CLS when they are inserted without reserved space; web.dev calls ads one of the largest contributors to layout shifts on the web.
  • Third-party scripts, including ad scripts, can occupy the main thread with long tasks, which delays the response to user interactions measured by INP.
  • The browser APIs used by RUM scripts do not report LCP elements or interactions inside iframes, but the metrics in Chrome UX Report data do include them.
  • Overlay Auto ads formats sit over the page without affecting layout, while in-page formats are inserted into the content.
A Grafana monitoring dashboard with performance graphs
Image: Grafana dashboard (2016),Linux Screenshots from USA,CC BY 2.0,via Wikimedia Commons.

AdSense ads affect Core Web Vitals in three different ways. They cause layout shift (CLS) when they land in space that was not reserved, they can add main-thread work that slows responses to taps and clicks (INP), and they compete for bandwidth with your main content (LCP). The thresholds are 2.5 seconds, 200 milliseconds and 0.1 at the 75th percentile. Measure with field data, because ad iframes hide part of the picture from lab tools and RUM scripts.

What are the targets?

From web.dev’s Web Vitals overview:

Metric Measures Good Where ads come in
LCP (Largest Contentful Paint) Loading: when the largest content element renders 2.5 s or less Ad requests compete with your content for network and CPU
INP (Interaction to Next Paint) Responsiveness to clicks, taps and key presses 200 ms or less Ad scripts and iframes can run long tasks on the main thread
CLS (Cumulative Layout Shift) Visual stability 0.1 or less Ads inserted without reserved space push content

The assessment uses “the 75th percentile of page loads, segmented across mobile and desktop devices”, and a page passes when all three metrics meet their target. Field data comes from the Chrome UX Report (CrUX), which feeds PageSpeed Insights and the Search Console Core Web Vitals report. For how to query it, see Chrome UX Report for publishers.

How do ads cause layout shift?

web.dev’s Optimize CLS is direct: “Ads are one of the largest contributors to layout shifts on the web.” The mechanism is simple. An empty <ins class="adsbygoogle"> takes no height until an ad arrives, then pushes everything below it.

What decides the impact:

  • Reserved space. A wrapper with min-height, or exact CSS sizes per breakpoint, removes most of the shift; both methods are covered in the CLS guide listed in the table below.
  • Position. Content injected near the top of the viewport “usually causes greater layout shifts” than content lower down.
  • Auto ads format. Overlay formats are placed “over a page’s content without affecting its layout”, per Google’s Auto ads settings. In-page formats are inserted into your content.
  • Collapsing empty slots. web.dev warns that removing reserved space “can cause just as much CLS as inserting content”.

CLS counts shifts during the whole page life, grouped in session windows, so ads that load while the reader scrolls count in the field even when a lab test never sees them.

How do ads affect INP?

INP measures how long the page takes to show the next frame after an interaction. web.dev’s INP article lists long tasks on the main thread as a cause of input delay: the browser cannot run your click handler while another task is running.

Ad code runs in two places:

  1. The loader in your page. adsbygoogle.js runs in your document, finds slots and creates iframes. That work shares your main thread.
  2. The ad iframes. web.dev’s third-party JavaScript guide notes that long tasks in third-party iframes “can block the main thread and delay other tasks”.

To find out whether ads are the problem, attribute long tasks to their frame. web.dev’s example uses a PerformanceObserver:

const observer = new PerformanceObserver((list) => {
  for (const entry of list.getEntries()) {
    // attribution includes the container of the frame that ran the task
    console.log(entry.duration, JSON.stringify(entry.attribution));
  }
});
observer.observe({ entryTypes: ["longtask"] });

Entries attributed to an ad iframe point to ad work; entries with your own document as the container point to your scripts, which you can change. Frameworks, carousels and tag managers are first-party costs too, so check before concluding.

How do ads affect LCP?

LCP is usually your own hero image, heading or text block. Ads affect it indirectly: requests to ad servers compete for bandwidth and CPU during load, especially on slow mobile connections.

Practical points:

  • Keep the loader async. Google’s generated code already uses async. Do not change it to a blocking script.
  • Do not place a large ad above your main content. If an ad slot is bigger than your hero, the largest element on screen may end up inside an ad iframe. web.dev explains that the metric counts elements within iframes, so an ad can become the page’s LCP element in field data.
  • Optimize your own LCP element first. Server response time, image size, preloading the hero image and fonts usually matter more than the ad script.

Why do RUM and CrUX disagree on ad pages?

Both the LCP and INP articles describe the same gap:

  • “The API does not consider elements within iframes but the metric does as they are part of the user experience of the page.”
  • “The API does not report event entries for interactions that occur within iframes but the metric does.”

Ads render in cross-origin iframes. A RUM script in your page, including the web-vitals library, cannot see an LCP element or an interaction inside them; Chrome’s own measurement, which feeds CrUX, can. web.dev adds that the web-vitals library handles most edge cases “except the iframe case”. So on ad pages, expect some difference between your RUM numbers and Search Console, and do not treat it as a bug in either. Set up RUM with web-vitals in production and read it alongside CrUX.

How do I measure the real impact of ads?

A single Lighthouse run cannot answer “how much do ads cost?”. A sounder process:

  1. Get field data per template. Group URLs by type (article, list, home) in CrUX or your RUM data. Ads behave differently per template.
  2. Compare with and without ads on comparable pages. For example, a set of articles excluded from Auto ads with page exclusions, against similar articles with ads. Page exclusions cannot be part of an AdSense experiment, so this is your own comparison.
  3. Give it time. CrUX field data covers a rolling window of past visits, so a change takes weeks to show fully.
  4. Record traces for the worst pages. Use the Performance panel’s Layout Shifts track and long task attribution to see what happened.
  5. Weigh it against revenue. A change that improves INP but removes your best-performing unit needs both sides of the ledger. Run setting changes as AdSense experiments where possible.

Automated lab checks still help catch regressions between deploys; see Lighthouse CI on ad pages.

What should I change first?

Problem First fix Guide
Poor CLS Reserve space for every manual slot; keep in-page Auto ads away from the top Prevent CLS from ads
CLS from Auto ads Lower ad load, use excluded areas, keep overlays Auto ads vs manual units
Poor INP Attribute long tasks; reduce your own scripts first; fewer ad units per page This guide
Poor LCP Optimize your hero element and server response; avoid a large ad above content This guide
Many units below the fold Defer their insertion until the reader nears them Lazy loading AdSense

Common mistakes

  • Blaming ads without attribution. Trace first; your own scripts may be the bigger cost.
  • Removing ads to pass a lab test. Lab scores are not what Search Console reports. Fix the cause in the field.
  • Collapsing slots to fix blank space. It trades blank space for layout shift.
  • Changing the loader to defer or moving it. Keep Google’s generated async code in the <head>, as Google instructs.
  • Testing on one device class only. Mobile and desktop are assessed separately; a fix verified on desktop may not help phones, where full-width ads and slower CPUs change the picture.
  • Reading CrUX the day after a fix. Field data is aggregated over weeks; a fix needs time to show.

Frequently asked questions

Do AdSense ads hurt Core Web Vitals?

They can, mainly through layout shift when ads are inserted without reserved space, and through main-thread work from ad scripts that can delay interactions. The effect depends on your layout, the number of units and your settings. Measure field data with and without ads on comparable pages rather than relying on general claims or a single Lighthouse score.

Why does my web-vitals RUM data differ from Search Console?

web.dev explains that the browser APIs do not report LCP elements or interactions inside iframes, while the metrics used by the Chrome UX Report include them because they are part of the user experience. Ads render in iframes, so a page where users interact with or see large ad content can show different values in CrUX-based tools and in your own RUM.

Do anchor and vignette ads cause layout shift?

Google describes overlay formats, which include anchor, vignette and side rail ads, as ads placed over a page's content without affecting its layout. They do not push content down the way in-page ads do. They can still affect other things, such as the screen space available on mobile, so check them on real devices after enabling them.

What should I fix first on an ad-heavy page?

Start with CLS, because reserving space for ad slots is the most direct fix and web.dev names ads among the largest sources of shifts. Then look at INP with a Performance trace to see whether long tasks come from your own scripts or third parties. LCP is usually driven by your own hero image, fonts and server response, so check those before blaming ads.

Sources

  1. Web Vitals · web.dev
  2. Optimize Cumulative Layout Shift · web.dev
  3. Interaction to Next Paint (INP) · web.dev
  4. Largest Contentful Paint (LCP) · web.dev
  5. Load third-party JavaScript · web.dev
  6. Auto ads settings · Google AdSense Help