Christiaan Bezuidenhout Biography, Net Worth, Age, Height, News, Wife, Girlfriend, Earnings & Religion

What is the use of “disableInitialLoad” on websites?

Spread the love

What is the use of “disableInitialLoad” on websites?

The disableInitialLoad() the method in Google Publisher Tag (GPT) is used to prevent ad slots from being fetched automatically when the GPT library is loaded and enableServices() is called.

🔍 What does disableInitialLoad() it do?

By default, once you call:

googletag.enableServices();

GPT will automatically request all ad slots that have been defined using googletag.defineSlot().

But if you use:

googletag.pubads().disableInitialLoad();

It stops that automatic loading. This gives you manual control over when ads are requested by using:
googletag.pubads().refresh();

Why use disableInitialLoad()?

  1. Header Bidding Integration (e.g., Prebid.js)
    • You often need to wait for header bidding to complete before making the GPT ad request.
    • This prevents GPT from firing too early, before the auction is ready.
  2. Lazy Loading or Deferred Loading
    • You may want to show ads only when they enter the viewport.
    • Using refresh() gives you control to load them at the right moment.
  3. Custom Ad Targeting Logic
    • Sometimes, targeting parameters or data are set dynamically (after page load).
    • This allows time to apply targeting before requesting the ad.

How it’s commonly used

<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
  window.googletag = window.googletag || { cmd: [] };
  googletag.cmd.push(function() {
    googletag.pubads().disableInitialLoad(); // Prevent automatic ad loading
    googletag.enableServices();
  });
</script>

Later, once everything is ready (e.g., bids returned), you can call:
googletag.pubads().refresh(); // Manually load ads

Without disableInitialLoad():

  • GPT will load ads as soon as enableServices() is called — you won’t be able to wait for other asynchronous operations (like header bidding or user consent).

Summary

FeatureWith disableInitialLoad()Without it
Ad loading controlManual (refresh())Automatic
Best forHeader bidding, lazy loadingSimple static ad loads
Risk of premature ad requestAvoidedPossible