避免使用会阻塞渲染的资源
概览
此项评估旨在找出会延迟加载广告代码库的资源(具体来讲,就是脚本和样式表)。这些是在广告代码库开始加载之前已请求和收到的资源。减少在代码加载之前请求的资源数量可加快广告加载速度。
建议
此项评估的结果详情包含一个列表,其中列出了所有会延迟代码加载的脚本和样式表。目标是减少此列表中的条目数量,使其尽可能接近 0。以下是一些关于执行此操作的提示:
- 在网页的
<head>
中更早地加载广告代码库。
- 将对核心功能至关重要的脚本和样式表直接内嵌到 HTML 中。
- 使用
async
或 defer
属性标记非关键脚本。
- 通过媒体查询将样式拆分为不同的文件,并使用
media
属性仅在需要时加载它们。
支持以下广告代码库脚本:
媒体库 |
脚本 |
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
|
会阻塞渲染的资源
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-06-26。
[null,null,["最后更新时间 (UTC):2024-06-26。"],[[["This audit helps identify scripts and stylesheets that slow down the loading of ad tags by being requested before them."],["Reducing the number of these resources loaded prior to ad tags can significantly improve ad loading speed."],["Optimization strategies include loading ad tags earlier, inlining critical resources, using `async` or `defer` for non-critical scripts, and separating stylesheets by media query."],["Supported ad tag libraries include AdSense and Google Publisher Tag, with specific script URLs for identification."]]],["The audit identifies scripts and stylesheets that delay ad tag library loading. To improve ad loading speed, reduce the number of resources requested before tag loading. Key actions include loading ad tag libraries earlier, inlining critical scripts/stylesheets, marking non-critical scripts with `async` or `defer`, and using the `media` attribute for conditional stylesheet loading. Supported ad tag libraries include AdSense and Google Publisher Tag, each with specific script URLs. The goal is to have minimal or zero items on this list.\n"]]