What is the use of “disableInitialLoad” on websites?
Table of Contents
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 usinggoogletag.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()
?
- 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.
- 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.
- 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
Feature | With disableInitialLoad() | Without it |
---|---|---|
Ad loading control | Manual (refresh() ) | Automatic |
Best for | Header bidding, lazy loading | Simple static ad loads |
Risk of premature ad request | Avoided | Possible |