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

PerformanceResourceTiming: responseEnd property

· 52CE 我爱测

The **`responseEnd`** read-only property returns a DOMHighResTimeStamp immediately after the browser receives the last byte of the resource or immediately before the transport connection is closed, whichever comes first.

Performance API

The responseEnd read-only property returns a DOMHighResTimeStamp immediately after the browser receives the last byte of the resource or immediately before the transport connection is closed, whichever comes first.

Value

A DOMHighResTimeStamp immediately after the browser receives the last byte of the resource or immediately before the transport connection is closed, whichever comes first.

Description

The responseEnd property is available for cross-origin requests without the Timing-Allow-Origin HTTP response header, except for navigations of cross-origin iframe elements.

Cross-origin iframes

For a cross-origin iframe, if the iframe's document is served with a Timing-Allow-Origin header that allows the embedding page's origin, responseEnd is the time immediately after the browser receives the last byte of that document.

Without this header, the precise time isn't reported, because it could reveal how the user interacted with the frame. Instead, the browser reports a fallback entry once the iframe's HTMLElement/load_event event fires. In this entry, PerformanceEntry.startTime is the time the iframe started navigating, and responseEnd is the time the iframe finished loading, including all of its subresources. The other timestamps, as well as the PerformanceResourceTiming.encodedBodySize and PerformanceResourceTiming.decodedBodySize properties, are 0.

Examples

Measuring time to fetch (without redirects)

The responseEnd and PerformanceResourceTiming.fetchStart properties can be used to measure the overall time it took to fetch the final resource (without redirects). If you want to include redirects, the overall time to fetch is provided in the PerformanceEntry.duration property.

const timeToFetch = entry.responseEnd - entry.fetchStart;

Example using a PerformanceObserver, which notifies of new resource performance entries as they are recorded in the browser's performance timeline. Use the buffered option to access entries from before the observer creation.

const observer = new PerformanceObserver((list) => {
  list.getEntries().forEach((entry) => {
    const timeToFetch = entry.responseEnd - entry.fetchStart;
    if (timeToFetch > 0) {
      console.log(`${entry.name}: Time to fetch: ${timeToFetch}ms`);
    }
  });
});

observer.observe({ type: "resource", buffered: true });

Example using Performance.getEntriesByType(), which only shows resource performance entries present in the browser's performance timeline at the time you call this method:

const resources = performance.getEntriesByType("resource");
resources.forEach((entry) => {
  const timeToFetch = entry.responseEnd - entry.fetchStart;
  if (timeToFetch > 0) {
    console.log(`${entry.name}: Time to fetch: ${timeToFetch}ms`);
  }
});

Specifications

Browser compatibility

See also

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

资料来源与适用范围

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

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

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