减少与广告相关的布局偏移
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
概览
Cumulative Layout Shift 通过使用 Layout Instability API 来衡量用户可见的布局偏移的总量,方法是汇总广告 iframe 发生布局偏移或导致布局偏移的所有布局偏移的布局偏移得分。
建议
此指标不代表具体问题。它应该用于帮助找出有待改进的领域并跟踪一段时间内的改进。
为避免布局偏移,请务必在广告代码加载之前为广告元素设置尺寸。这种做法可能很难实现或无法完美实现(尤其是对于接受动态尺寸广告的广告位),但在大多数情况下,您可以遵循一些最佳做法来尽可能减少布局偏移。如需了解详情,请参阅 GPT 开发者网站上的与尽可能减少布局偏移有关的指南。
Cumulative Layout Shift (CLS)
优化 Cumulative Layout Shift
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eCumulative Layout Shift (CLS) quantifies the total visual instability caused by ad iframes shifting or inducing layout changes, using the Layout Instability API and layout shift scores.\u003c/p\u003e\n"],["\u003cp\u003eThis metric helps pinpoint areas for improvement and track progress rather than diagnosing specific issues.\u003c/p\u003e\n"],["\u003cp\u003eMinimizing layout shift is crucial and involves pre-setting ad element sizes, though achieving perfection is challenging, especially with dynamic ads.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the GPT developer guide for best practices in minimizing layout shift for most scenarios.\u003c/p\u003e\n"]]],["Cumulative Layout Shift (CLS) measures user-visible layout shifts, specifically those caused by or involving ad iframes. It uses the Layout Instability API and sums the layout shift score. Recommendations include setting sizes for ad elements before loading to minimize shifts. While perfect prevention is difficult, especially for dynamically sized ads, best practices are suggested. This metric helps track improvements, not pinpoint issues. Resources are available for further optimization and guidance.\n"],null,["# Reduce ad-related layout shift\n\nOverview\n--------\n\nCumulative Layout Shift measures the total amount of user-visible layout shift\nusing the [Layout Instability API](https://wicg.github.io/layout-instability/)\nby summing the [layout shift score](https://web.dev/cls/#layout-shift-score) for\nall layout shifts where the ad iframe shifted or caused the layout shift.\n\nRecommendations\n---------------\n\nThis metric is not indicative of a specific issue. It should be used to help\nidentify areas for improvement and track that improvement over time.\n\nTo avoid layout shift, it's important to set sizes for ad elements before the\nad tag loads. This can be difficult or impossible to do perfectly---especially for\nad slots that accept dynamically sized ads---but there are best practices you can\nfollow to minimize layout shift in most cases. For more information, see the\n[guide to minimizing layout shift](https://developers.google.com/publisher-tag/guides/minimize-layout-shift)\nat the GPT developer site.\n\nMore information\n----------------\n\n[Cumulative Layout Shift (CLS)](https://web.dev/cls/)\n\n[Optimize Cumulative Layout Shift](https://web.dev/optimize-cls/) \n[View audit source](https://github.com/googleads/publisher-ads-lighthouse-plugin/tree/HEAD/lighthouse-plugin-publisher-ads/audits/cumulative-ad-shift.js) [Improve this article](https://github.com/googleads/publisher-ads-lighthouse-plugin/tree/HEAD/docs/audits/cumulative-ad-shift.md) [Report an issue](https://github.com/googleads/publisher-ads-lighthouse-plugin/issues/new?labels=documentation&template=documentation-feedback.md&title=Documentation+feedback%3A+cumulative-ad-shift.md)\n\n\u003cbr /\u003e"]]