Ad code & integration

Lazy loading AdSense ads: safe patterns, documented limits and what to measure

Last updated Published By the editorial team6 min5 sources

Key takeaways

  • AdSense Help does not document a lazy-loading setting or a lazy-loading pattern for manual ad units; Google Publisher Tag, the Ad Manager tag, has one.
  • The AdSense loader is already async; web.dev recommends async or defer for third-party scripts and names footer ads as an example of content to lazy load.
  • Google warns that ad units which are not initially visible may not send an ad request, so never load a unit hidden and reveal it later.
  • A safer pattern inserts the ins element only when its reserved placeholder nears the viewport, then calls push once for that new slot.
  • Google documents pauseAdRequests and deferring adsbygoogle.js for consent, which shows the loader can be delayed, but not for performance tuning.
An analog stopwatch
Image: Analog Stop Watch,Jeremyida002,CC BY-SA 4.0,via Wikimedia Commons.

Lazy loading AdSense means requesting below-the-fold ads only when the reader scrolls near them. Google’s AdSense Help does not document a lazy-loading feature or pattern for manual units, so any approach is your own code. The safe version keeps the ad unit unmodified and visible: reserve the slot’s space, insert the <ins> when its placeholder nears the viewport, then push once. Never hide units to reveal them later.

What does Google actually document?

Three Google sources touch the topic, none of them an AdSense lazy-loading guide:

Source What it says What it means for AdSense
web.dev, Load third-party JavaScript Lazy loading can wait “to serve ads in the page footer until the user scrolls far enough to see them”; use async or defer for third-party scripts General performance advice; the AdSense loader is already async
Google Publisher Tag, Lazy loading sample Lazy loading pauses “the requesting and rendering of ads until they approach the user’s viewport” and can improve viewability GPT feature for Ad Manager tags; not available in adsbygoogle.js
AdSense, data-ad-status article “If ad units aren’t initially visible on the page, we may not execute the ad request for that ad unit.” Hidden-then-revealed units can stay empty

web.dev also warns: “Be careful when lazy loading resources, because it often involves JavaScript code that can be impacted by flaky network connections.”

Why lazy load at all?

The usual reasons, and their limits:

  • Less work during page load. Fewer ad requests and iframes compete with your content at the start. This can help main-thread work and network contention; whether it moves your Core Web Vitals depends on your page, so measure it (see Ads and Core Web Vitals).
  • Viewability. Ads requested near the viewport have a better chance of being seen. GPT cites improved viewability as a benefit of its feature. For how AdSense measures it, see Active View viewability.
  • The cost. Readers who leave before scrolling never request the lower ads. Total impressions usually fall; whether revenue follows depends on your traffic. There is no general number to rely on.

What should you never do?

  • Load units with display:none and show them later. Google says hidden units may never send a request, and the code modification policy forbids hiding ad units, outside the documented responsive media query method.
  • Lazy load above the fold. A top slot that loads late pushes content in front of the reader. web.dev notes content injected near the top of the viewport “usually causes greater layout shifts”.
  • Re-request ads as users scroll back and forth. Pushing the same slot again, or replacing filled units to get fresh ads, is a refresh. The ad placement policies do not allow auto-refreshing ads without a user request.
  • Copy or self-host adsbygoogle.js. web.dev lists self-hosting as an option for third-party scripts in general. For AdSense, load the library from Google’s URL exactly as provided.
  • Add loading="lazy" to the <ins>. It has no effect on that element, and the ad iframes are created by the library.

A safe pattern: insert the unit near the viewport

A plain push({}) fills the first unprocessed <ins> in the page. If several lazy units sit in the HTML from the start, a push triggered by one of them may fill another. The robust approach keeps only placeholders in the HTML and creates each <ins> when it is needed, so the push always has exactly one new slot to fill.

The placeholder reserves the space:

<div class="ad-slot ad-slot--lazy" data-ad-slot="1234567890"></div>
.ad-slot--lazy { min-height: 280px; }

The script, loaded after the AdSense code that stays in the <head>:

const CLIENT = "ca-pub-0000000000000000";

function fillSlot(placeholder) {
  const ins = document.createElement("ins");
  ins.className = "adsbygoogle";
  ins.style.display = "block";
  ins.dataset.adClient = CLIENT;
  ins.dataset.adSlot = placeholder.dataset.adSlot;
  ins.dataset.adFormat = "auto";
  ins.dataset.fullWidthResponsive = "true";
  placeholder.appendChild(ins);
  (window.adsbygoogle = window.adsbygoogle || []).push({});
}

const observer = new IntersectionObserver((entries) => {
  for (const entry of entries) {
    if (!entry.isIntersecting) continue;
    observer.unobserve(entry.target);
    fillSlot(entry.target);
  }
}, { rootMargin: "600px 0px" });

document.querySelectorAll(".ad-slot--lazy").forEach((el) => observer.observe(el));

Notes:

  • dataset.adClient becomes data-ad-client, and so on. The element ends up with the same attributes as Google’s generated responsive code; nothing is changed or added to the ad markup.
  • unobserve ensures each placeholder is filled once. The unit is never re-requested.
  • rootMargin starts the request before the slot enters the screen, so the ad usually arrives before the reader does. 600px is a starting point to tune, not a Google figure.
  • Keep the first one or two slots as normal units in the HTML. Lazy load only what sits well below the first screen.
  • The placeholder is visible and has a width when the <ins> is inserted, which avoids the “No slot size for availableWidth=0” error the library logs for zero-width slots.

The same rule, one push per newly inserted slot, applies to client-side navigation in frameworks; the single-page apps guide covers route changes.

Can I delay the whole AdSense script?

Google documents delaying the library in one context: consent. Its ads personalization settings article describes setting (adsbygoogle=window.adsbygoogle||[]).pauseAdRequests=1 before any push(), then pauseAdRequests=0 once the user has chosen, and warns: “If you don’t set pauseAdRequests=0, no ads will appear.” It adds that a consent tool can instead “defer loading gpt.js and adsbygoogle.js” until the user has made a choice. For the consent side, see Consent Mode v2 and AdSense.

Delaying the script for performance, for example until the first scroll or a few seconds after load, is a different decision:

Effect Why
Every ad is delayed, including Auto ads and overlays Auto ads rely on the same head script
Short visits may see no ads The script never loads if the reader leaves first
Top slots fill late Late fills near the top cause layout shift unless space is reserved

If you test it, do it on part of your traffic and compare page RPM, not only lab scores. Google’s Auto ads experiments cannot split this kind of code change for you, so you need your own split by section or template.

Does lazy loading apply to Auto ads?

No. With Auto ads, Google decides where and when in-page and overlay ads appear; there is no <ins> of yours to observe or defer, and Google does not document a lazy-loading control for them. The levers you have are the settings Google does document in Auto ads settings: “Maximum number of ads on a page”, “Minimum distance between ads on a page”, excluded areas and excluded pages. If you combine Auto ads with manual units, apply the placeholder pattern only to your manual units below the fold and leave Auto ads to Google.

How do I check that it works?

  1. Open DevTools, Network panel, filter on googlesyndication. Load a long article: only the loader and the first slots should request ads at first.
  2. Scroll slowly. Each lazy slot should request once as you approach it, and not again when you scroll back.
  3. Check the console for adsbygoogle.push() error messages, which mean more pushes than empty slots.
  4. Check data-ad-status on each <ins> after it loads (filled or unfilled).
  5. Record a Performance trace while scrolling and look at the Layout Shifts track for the lazy slots.

Common mistakes

  • Observing the <ins> instead of a placeholder. The push may fill a different unit than the one you observed.
  • No reserved height. Lazy slots without min-height shift content as each ad lands.
  • A tiny rootMargin. Ads that start loading at the viewport edge often arrive after the reader has scrolled past.
  • Lazy loading every unit. The first screen loses its ads and gains layout shift.
  • Judging success on Lighthouse alone. Lab tests load the top of the page; the lazy slots barely appear in them. Use field data and AdSense reports.

Frequently asked questions

Does AdSense lazy load ads automatically?

Google's AdSense Help does not describe a built-in lazy-loading option for manual ad units, and there is no setting for it in the ad unit editor. Google Publisher Tag, used with Ad Manager, has a documented lazy-loading feature, but its methods do not apply to adsbygoogle.js. Do not assume either way; measure when your slots request ads in the browser's network panel.

Is lazy loading AdSense ads against the policies?

No AdSense page found for this guide explicitly allows or bans it. The relevant limits are clear, though: the code modification policy forbids changes that artificially inflate ad performance or hide ads, and Google warns that units not initially visible may not request ads. Deferring when a visible, unmodified unit is inserted and pushed stays clear of both. Test it in a limited section first.

Can I add loading="lazy" to the AdSense code?

No. The loading attribute works on img and iframe elements you write yourself. The ins element is not an image or a frame, and the iframes that show ads are created by the AdSense library, so you cannot set attributes on them. Adding unknown attributes to the generated code is also a modification Google does not document.

Should I delay the AdSense script until the user interacts?

Only with care. Delaying adsbygoogle.js delays every ad on the page, including Auto ads and top slots, so fewer ads load for short visits. Google documents delaying the script for one case, consent: a CMP can defer loading it, or pauseAdRequests can hold requests until a choice is made. For performance alone, test the effect on earnings with real data before keeping it.

Sources

  1. Load third-party JavaScript · web.dev
  2. Lazy loading (sample) · Google Publisher Tag (Google for Developers)
  3. Ads personalization settings in Google's publisher ad tags · Google AdSense Help
  4. Use the data-ad-status parameter to hide unfilled ad units · Google AdSense Help
  5. Optimize Cumulative Layout Shift · web.dev