异步加载广告代码
概览
此项审核旨在确保异步加载广告代码库脚本。
默认情况下,JavaScript 执行是同步的。也就是说,脚本
则在该脚本完成之前,不能加载其他内容。
已下载、解析和执行。选择启用异步执行可防止
这样,浏览器在
指定的脚本在后台加载。这样可确保您的网页在脚本加载期间仍能灵敏地做出响应,并缩短所有关键组件的加载用时。
建议
在脚本代码定义中添加 async 属性。例如:
AdSense
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
AdSense(自动广告)
<script async data-ad-client="ca-pub-xxxxxxxxxxxxxxxx" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
Google 发布商代码
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
支持以下广告代码库脚本:
广告代码库 |
脚本 |
AdSense |
pagead2.googlesyndication.com/pagead/js/adsbygoogle.js
pagead2.googlesyndication.com/pagead/show_ads.js
|
Google 发布商代码 |
googletagservices.com/tag/js/gpt.js
securepubads.g.doubleclick.net/tag/js/gpt.js
|
Google 发布商代码使用入门
GPT 请求模式和异步呈现
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-10-15。
[null,null,["最后更新时间 (UTC):2024-10-15。"],[[["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."]]],[]]