# 最大内容绘制

**最大内容绘制**（Largest Contentful Paint，LCP）是一项网页性能指标，报告视口内可见的最大图片、文本块或视频的渲染时间，计时起点是用户首次导航到该页面的时刻。<sup>[1](https://web.dev/articles/lcp?authuser=00)</sup> 它是 Google 三项[核心网页指标](https://www.edgepedia.org/zh/core-web-vitals)（Core Web Vitals）之一——这套指标从加载性能、交互性和视觉稳定性三方面衡量真实用户的使用体验——LCP 在其中负责加载性能。<sup>[2](https://developers.google.com/search/docs/appearance/core-web-vitals)</sup> 配套的 W3C 规范 LargestContentfulPaint API 将该指标暴露给 [JavaScript](https://www.edgepedia.org/zh/javascript)，使开发者能够观察是哪个元素被绘制、以及何时绘制。<sup>[3](https://www.w3.org/TR/largest-contentful-paint/)</sup>

| 关键事实 | 说明 |
|---|---|
| 衡量对象 | 视口内可见的最大图片、文本块或视频的渲染时间，相对于导航开始时刻<sup>[1](https://web.dev/articles/lcp?authuser=00)</sup> |
| 良好阈值 | 2.5 秒及以内；超过 4.0 秒为差；按页面浏览量的第 75 百分位评估<sup>[4](https://github.com/GoogleChrome/web.dev/blob/main/src/site/content/en/blog/defining-core-web-vitals-thresholds/index.md)</sup> |
| 算法终止 | 在用户首次输入（不含鼠标移动、进入、离开与捏合手势）时，或页面导航离开时停止观测<sup>[5](https://github.com/w3c/largest-contentful-paint)</sup> |
| 被移除的元素 | 从 DOM 中移除的元素不会被排除在 LCP 候选之外，此规则是为处理图片轮播而加入的<sup>[5](https://github.com/w3c/largest-contentful-paint)</sup> |
| 尺寸单位 | API 使用并返回的元素尺寸单位为设备无关像素的平方<sup>[5](https://github.com/w3c/largest-contentful-paint)</sup> |
| 包含的延迟 | LCP 包含上一页面的卸载时间、连接建立、重定向时间以及其他首字节时间（TTFB）延迟<sup>[1](https://web.dev/articles/lcp?authuser=00)</sup> |
| 核心网页指标状态 | 自 2020 年起为三项核心网页指标之一；2024 年 3 月 12 日，交互到下一次绘制在该指标集中取代了首次输入延迟<sup>[2](https://developers.google.com/search/docs/appearance/core-web-vitals)</sup><sup> • </sup><sup>[6](https://developers.google.com/search/blog/2021/11/bringing-page-experience-to-desktop?hl=en)</sup> |

## 为什么需要这项指标

`load`、`DOMContentLoaded` 等较早的页面加载指标未必对应用户在屏幕上看到的内容，而[首次内容绘制](https://www.edgepedia.org/zh/first-contentful-paint)只捕捉到加载体验的最开头。此前用于标记主要内容何时出现的尝试，如首次有效绘制（First Meaningful Paint，FMP）和[速度指数](https://www.edgepedia.org/zh/speed-index-web-performance)（Speed Index），被 Google 形容为复杂、难以解释且常常出错。Google 内部的研究以及 W3C 网页性能工作组（Web Performance Working Group）的讨论得出一个结论：最大元素完成渲染的时刻，能更准确地代表页面主要内容加载完成的时刻。<sup>[1](https://web.dev/articles/lcp?authuser=00)</sup>

“有内容的”一词有特定含义。该指标意在表示主要内容送达的速度，但“主要内容”的定义是主观的，因此 LCP 用最大的“有内容的”元素来近似。FMP 依赖复杂的启发式规则，相比之下 LCP 使用的启发式规则更简单；规范作者称，这使其结果更易解读，也更容易被浏览器厂商实现。<sup>[5](https://github.com/w3c/largest-contentful-paint)</sup>

## 算法如何工作

页面加载期间，浏览器持续跟踪迄今已绘制的内容；每当发现新的最大元素，就通过 `PerformanceObserver` 派发一条新的 `largest-contentful-paint` 条目。在一个同时有文本和主图的页面上，浏览器可能先渲染文本，产生一条元素为 `<p>` 或 `<h1>` 的条目，随后在图片绘制时再产生一条条目。<sup>[1](https://web.dev/articles/lcp?authuser=00)</sup> 算法停止前的最后一个候选，就是所报告的 LCP 值。

**终止条件。** 当用户进行首次输入，或页面导航离开时，算法停止观测。首次输入包括除鼠标移动、鼠标进入、鼠标离开和捏合手势之外的所有输入类型。规范还指出，只要发生滚动或输入事件，算法即终止，因为这些事件很可能向页面引入新内容。<sup>[5](https://github.com/w3c/largest-contentful-paint)</sup><sup> • </sup><sup>[3](https://www.w3.org/TR/largest-contentful-paint/)</sup>

**被移除的元素。** 如果某个内容元素从 DOM 树中被移除，它不会被排除在 LCP 候选之外。此规则的存在，是为了让 LCP 在图片轮播这类可见幻灯片会切换的场景中也能被正确计算；这也意味着，使用大块占位内容的启动画面可以被记录为 LCP 元素。<sup>[5](https://github.com/w3c/largest-contentful-paint)</sup><sup> • </sup><sup>[3](https://www.w3.org/TR/largest-contentful-paint/)</sup>

**已知局限。** 规范称该 API 基于启发式规则，因而容易出错。如果用户输入发生在主要内容显示之前，算法会中止，可能产生无意义的结果，或完全不产生结果。在屏幕外加载的页面，例如后台标签页中的页面或通过预渲染加载的页面，会报告比预期更大的值，因为它们度量的是从加载到绘制的时间。该 API 基于文档加载，因此在往返缓存（bfcache）恢复时，或在单页应用使用的同文档历史导航时，它不会被重置，尽管用户会把这类情况体验为页面加载。<sup>[3](https://www.w3.org/TR/largest-contentful-paint/)</sup> 页面从往返缓存恢复时，该 API 也不会报告条目；而在某些情况下，例如跨源 iframe，LCP 根本无法用 JavaScript 测量；`web-vitals` JavaScript 库处理了其中许多差异。<sup>[7](https://web.dev/articles/lcp?external_link=true)</sup>

## 阈值与测量

核心网页指标的阈值将 LCP 在 2.5 秒（2500 毫秒）及以内判为良好，超过 4.0 秒判为差，介于两者之间的值需要改进。评估采用页面浏览量的第 75 百分位：若某站点至少 75% 的页面浏览量达到良好阈值，则该指标判为良好；若至少 25% 达到差阈值，则判为差。<sup>[4](https://github.com/GoogleChrome/web.dev/blob/main/src/site/content/en/blog/defining-core-web-vitals-thresholds/index.md)</sup>

实测数据依赖 Chrome 用户体验报告（Chrome User Experience Report，CrUX），这是一个反映真实 Chrome 用户如何体验热门网站的数据集。自 2017 年在 BigQuery 上发布以来，CrUX 数据已被集成到 PageSpeed Insights 和 Search Console 的核心网页指标报告等工具中，CrUX API 则在源站和 URL 两个层级报告 LCP、INP 和 CLS。<sup>[8](https://developer.chrome.com/docs/crux/guides/crux-api?authuser=86)</sup> 由于 LCP 包含上一页面的卸载时间、连接建立、重定向时间以及其他 TTFB 延迟，实测结果可能与实验室测量结果有明显差异。<sup>[1](https://web.dev/articles/lcp?authuser=00)</sup>

## 优化

页面的 LCP 资源（如果存在）要么是图片，要么是网页字体；其加载速度取决于两个因素：资源何时被发现，以及浏览器赋予它什么优先级。<sup>[9](https://web.dev/articles/optimize-lcp?authuser=1)</sup> 当元素是 `<img>` 且其 `src` 或 `srcset` 出现在标记中时，或当所需的 CSS 背景图片或网页字体通过 `<link rel="preload">` 预加载时，浏览器的预加载扫描器可以在初始 HTML 响应中就发现 LCP 资源。无法以这种方式被发现的资源，例如由 JavaScript 添加的图片、`src` 藏在 `data-src` 属性中的懒加载图片，或未预加载的 CSS 背景图片，会较晚才开始加载，因为浏览器必须先执行脚本或应用样式表。<sup>[10](https://web.dev/articles/optimize-lcp?authuser=10)</sup>

**优先级提示。** 图片默认以低抓取优先级开始，若位于视口内，则在布局时被提升为高优先级，这段延迟可能拖慢主图。`fetchpriority="high"` 属性可让重要图片立即以高优先级开始。在 [Google Flights](https://www.edgepedia.org/zh/google-flights) 首页的一次测试中，为 LCP 背景图片加上抓取优先级后，LCP 从 2.6 秒改善到 1.9 秒。<sup>[11](https://web.dev/articles/fetch-priority?hl=en)</sup> 在 LCP 图片上设置 `loading="lazy"` 则效果相反，是明确不推荐的做法，因为该资源要等到布局确认它位于视口内才会开始加载。<sup>[10](https://web.dev/articles/optimize-lcp?authuser=10)</sup>

案例研究量化了这些改动的价值。巴西房地产平台 QuintoAndar 将实验室 LCP 从 2.41 秒降至 1.48 秒，改善 39%，其移动端第 75 百分位实测 LCP 下降了 26%。GoDaddy 的 Websites + [Marketing](https://www.edgepedia.org/zh/marketing) 服务通过减少打包体积、延迟 JavaScript 和图片优化，将客户 [Lighthouse](https://www.edgepedia.org/zh/lighthouse) 平均得分从 2020 年 11 月的约 40 分提升到 2021 年 5 月的 70 分以上，这些收益中也包括 LCP。<sup>[12](https://web.dev/case-studies/quintoandar?hl=en)</sup><sup> • </sup><sup>[13](https://web.dev/case-studies/godaddy?hl=en)</sup>

## 在搜索排名中的作用

Google 于 2020 年 5 月宣布，页面体验信号将被纳入搜索排名，其可度量的核心正是核心网页指标；页面体验更新于 2021 年 6 月开始推出。同样的信号自 2022 年 2 月起扩展到桌面端排名，并于 2022 年 3 月底完成，所用的核心网页指标与移动端相同。<sup>[6](https://developers.google.com/search/blog/2021/11/bringing-page-experience-to-desktop?hl=en)</sup> Google 搜索中心（Search Central）的文档建议站点力争在页面开始加载后的 2.5 秒内完成 LCP。<sup>[2](https://developers.google.com/search/docs/appearance/core-web-vitals)</sup>

## References

1. [Largest Contentful Paint (LCP), web.dev](https://web.dev/articles/lcp?authuser=00)
2. [Understanding Core Web Vitals and Google search results, Google Search Central](https://developers.google.com/search/docs/appearance/core-web-vitals)
3. [Largest Contentful Paint, W3C Working Draft](https://www.w3.org/TR/largest-contentful-paint/)
4. [Defining the Core Web Vitals metric thresholds, web.dev (GoogleChrome/web.dev GitHub)](https://github.com/GoogleChrome/web.dev/blob/main/src/site/content/en/blog/defining-core-web-vitals-thresholds/index.md)
5. [w3c/largest-contentful-paint specification repository, GitHub](https://github.com/w3c/largest-contentful-paint)
6. [Timeline for bringing page experience ranking to desktop, Google Search Central Blog](https://developers.google.com/search/blog/2021/11/bringing-page-experience-to-desktop?hl=en)
7. [Largest Contentful Paint (LCP), web.dev (external link version)](https://web.dev/articles/lcp?external_link=true)
8. [How to use the CrUX API, Chrome for Developers](https://developer.chrome.com/docs/crux/guides/crux-api?authuser=86)
9. [Optimize Largest Contentful Paint, web.dev](https://web.dev/articles/optimize-lcp?authuser=1)
10. [Optimize Largest Contentful Paint, web.dev (authuser=10 version)](https://web.dev/articles/optimize-lcp?authuser=10)
11. [Optimize resource loading with the Fetch Priority API, web.dev](https://web.dev/articles/fetch-priority?hl=en)
12. [How QuintoAndar increased conversion rates and pages per session, web.dev case study](https://web.dev/case-studies/quintoandar?hl=en)
13. [How GoDaddy's Websites + Marketing service improved customer Core Web Vitals by 75%, web.dev case study](https://web.dev/case-studies/godaddy?hl=en)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Web development and web-platform technologies › Web performance metrics

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/largest-contentful-paint

English original: https://www.edgepedia.org/largest-contentful-paint
