大网数据广告活动
Web 标准与前端开发

LargestContentfulPaint: renderTime property

· 52CE 我爱测

The **`renderTime`** read-only property of the LargestContentfulPaint interface represents the time that the element was rendered to the screen.

Performance API

The renderTime read-only property of the LargestContentfulPaint interface represents the time that the element was rendered to the screen.

Value

The renderTime property can have the following values:

  • A DOMHighResTimeStamp representing the time in milliseconds that the element was rendered to the screen.
  • 0 or a coarsened DOMHighResTimeStamp if the resource is a cross-origin request and no Timing-Allow-Origin HTTP response header is used.

Cross-origin image render time

For security reasons, the value of the renderTime property was originally 0 if the resource is a cross-origin request.

Browsers may now expose a slightly coarsened render time in these situations. Check for browser support.

To expose more accurate cross-origin render-time information, the Timing-Allow-Origin HTTP response header needs to be set.

For example, to allow https://developer.mozilla.org to see an accurate renderTime, the cross-origin resource should send:

Timing-Allow-Origin: https://developer.mozilla.org

Use startTime over renderTime

Regardless of the accuracy of the renderTime, developers should use PerformanceEntry.startTime over renderTime as the LCP time. This returns the value of the entry's renderTime if it is not 0, and otherwise the value of this entry's LargestContentfulPaint.loadTime so removes the need to check for 0 values for non-supporting browsers.

Examples

Logging the renderTime of the largest contentful paint

This example uses a PerformanceObserver notifying of new largest-contentful-paint performance entries as they are recorded in the browser's performance timeline. The buffered option is used to access entries from before the observer creation.

const observer = new PerformanceObserver((list) => {
  const entries = list.getEntries();
  const lastEntry = entries[entries.length - 1]; // Use the latest LCP candidate
  console.log(lastEntry.renderTime);
});
observer.observe({ type: "largest-contentful-paint", buffered: true });

Specifications

Browser compatibility

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。