避免使用会阻塞渲染的资源
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
概览
此项评估旨在找出会延迟加载广告代码库的资源(具体来讲,就是脚本和样式表)。这些是在广告代码库开始加载之前已请求和收到的资源。减少在代码加载之前请求的资源数量可加快广告加载速度。
建议
此项评估的结果详情包含一个列表,其中列出了所有会延迟代码加载的脚本和样式表。目标是减少此列表中的条目数量,使其尽可能接近 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):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eThis audit helps identify scripts and stylesheets that slow down the loading of ad tags by being requested before them.\u003c/p\u003e\n"],["\u003cp\u003eReducing the number of these resources loaded prior to ad tags can significantly improve ad loading speed.\u003c/p\u003e\n"],["\u003cp\u003eOptimization strategies include loading ad tags earlier, inlining critical resources, using \u003ccode\u003easync\u003c/code\u003e or \u003ccode\u003edefer\u003c/code\u003e for non-critical scripts, and separating stylesheets by media query.\u003c/p\u003e\n"],["\u003cp\u003eSupported ad tag libraries include AdSense and Google Publisher Tag, with specific script URLs for identification.\u003c/p\u003e\n"]]],["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"],null,["# Avoid render-blocking resources\n\nOverview\n--------\n\nThis audit identifies resources (specifically scripts and stylesheets) which are\ndelaying the loading of ad tag libraries. These are resources that were\nrequested and received before ad tag libraries began loading. Reducing the\nnumber of resources requested prior to tag load will speed up ad loading.\n\nRecommendations\n---------------\n\nThe details of this audit contain a list of all scripts and stylesheets that are\ndelaying tag load. The goal is to reduce the number of entries in this list as\nclose to 0 as possible. Some tips for doing this include:\n\n- Loading ad tag libraries earlier in the `\u003chead\u003e` of the page.\n- Inlining scripts and stylesheets critical to core functionality directly into your HTML.\n- Marking non-critical scripts with the `async` or `defer` attributes.\n- Separating styles into different files by media query and using the `media` attribute to load them only when needed.\n\nMore information\n----------------\n\nThe following ad tag library scripts are supported:\n\n| Library | Script(s) |\n|----------------------|-------------------------------------------------------------------------------------------------------------|\n| AdSense | `pagead2.googlesyndication.com/pagead/js/adsbygoogle.js` `pagead2.googlesyndication.com/pagead/show_ads.js` |\n| Google Publisher Tag | `googletagservices.com/tag/js/gpt.js` `securepubads.g.doubleclick.net/tag/js/gpt.js` |\n\n[Rendering Blocking Resources](https://developers.google.com/web/tools/lighthouse/audits/blocking-resources) \n[View audit source](https://github.com/googleads/publisher-ads-lighthouse-plugin/tree/HEAD/lighthouse-plugin-publisher-ads/audits/ad-render-blocking-resources.js) [Improve this article](https://github.com/googleads/publisher-ads-lighthouse-plugin/tree/HEAD/docs/audits/ad-render-blocking-resources.md) [Report an issue](https://github.com/googleads/publisher-ads-lighthouse-plugin/issues/new?labels=documentation&template=documentation-feedback.md&title=Documentation+feedback%3A+ad-render-blocking-resources.md)\n\n\u003cbr /\u003e"]]