Load ad tag asynchronously
Stay organized with collections
Save and categorize content based on your preferences.
Overview
This audit ensures ad tag library scripts are loaded asynchronously.
By default, JavaScript execution is synchronous. This means that once a script
is encountered, no other content can be loaded until that script has been
downloaded, parsed, and executed. Opting into asynchronous execution prevents
this, allowing the browser to continue processing other resources while the
specified script is loaded in the background. This keeps your page responsive
while scripts are loading and decreses the time necessary to load all critical
components.
Recommendations
Include the async attribute in the script tag definition. For example:
AdSense
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
AdSense (auto ads)
<script async data-ad-client="ca-pub-xxxxxxxxxxxxxxxx" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
Google Publisher Tag
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
The following ad tag library scripts are supported:
Ad Tag Library |
Script(s) |
AdSense |
pagead2.googlesyndication.com/pagead/js/adsbygoogle.js
pagead2.googlesyndication.com/pagead/show_ads.js
|
Google Publisher Tag |
googletagservices.com/tag/js/gpt.js
securepubads.g.doubleclick.net/tag/js/gpt.js
|
Get Started with Google Publisher Tags
GPT request modes and asynchronous rendering
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-06-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-06-26 UTC."],[[["This audit verifies if ad tag library scripts are loaded asynchronously to improve page performance."],["Asynchronous loading allows the browser to load other content while the script loads in the background, preventing delays and improving user experience."],["To enable asynchronous loading, include the `async` attribute within the `\u003cscript\u003e` tag when implementing ad tags like AdSense and Google Publisher Tag."],["Synchronous loading, where the browser waits for the script to fully load before proceeding, can negatively impact page load times and overall performance."]]],[]]