导航时序 第二级

W3C 工作草案,

关于本文件的更多详情
当前版本:
https://www.w3.org/TR/2026/WD-navigation-timing-2-20260901/
最新发布版本:
https://www.w3.org/TR/navigation-timing-2/
编辑草案:
https://w3c.github.io/navigation-timing/
旧版本:
历史记录:
https://www.w3.org/standards/history/navigation-timing-2/
反馈建议:
public-web-perf@w3.org 邮件主题行 “[navigation-timing-2] … 信息主题 …” (档案)
GitHub
测试套件:
https://wpt.fyi/navigation-timing/
编辑者:
Yoav Weiss (Shopify)
(Google)
前编辑者:
Ilya Grigorik (Google)
(微软公司 )
(微软公司 )
(谷歌公司)

摘要

本规范定义了一个接口,使网页应用能够访问文档导航的完整时序信息。

本文档状态

本节描述了本文档在发布时的状态。 当前的 W3C 出版物列表和本技术报告的最新修订版 可在 W3C 标准与草案索引中找到。

本文档由Web 性能工作组作为工作草案 按照 推荐轨道发布。 作为工作草案发布 并不代表 W3C及其成员的认可。

此为草案文档, 可能随时被更新、替换或废弃, 不宜作为除“进展中工作”之外的引用依据。

GitHub 问题是讨论本规范优选渠道。

本文档受 2025年8月18日 W3C 流程文件 约束。

本文档由按照 W3C 专利政策运作的团体产生。 W3C 维护着 所有相关专利披露的公开列表 ,该页面还包括披露专利的说明。 如有个人实际知晓某专利,且认为 包含必要声明 ,须依据 W3C 专利政策第6节 披露该信息。

Navigation Timing 2 替代了第一版[NAVIGATION-TIMING] 主要变更如下:

1. 简介

本节为非规范性内容。

准确衡量网页应用的性能特性是提升网页速度的重要部分。虽然 JavaScript 机制(如[JSMEASURE]所述)可为应用内 用户延迟测量提供全面的工具,但 在很多情况下,无法提供完整或详细的端到端延迟图景。 例如,下方 JavaScript 展示了测量页面完全加载时间的一个简单尝试:

<html>
<head>
<script type="text/javascript">
var start = new Date().getTime();
function onLoad() {
  var now = new Date().getTime();
  var latency = now - start;
  alert("page loading time: " + latency);
}
</script>
</head>
<body onload="onLoad()">
<!- 主页面内容从这里开始 -->
</body>
</html>

上述脚本是计算页面加载所需时间, 在head 内首段 JavaScript 执行之后,但 不能反映页面从服务器获取或页面初始化生命周期的耗时。

本规范定义了 PerformanceNavigationTiming 接口,该接口参与[PERFORMANCE-TIMELINE-2]以存取 与文档导航相关的高精度性能指标数据。由于 PerformanceNavigationTiming 接口采用 [HR-TIME], 所有时间值均以条目的 时间原点 与其相关设置对象为基准衡量。

例如,如果 response end 在导航开始后 100ms 发生,PerformanceNavigationTiming 数据可能如下:

startTime:           0.000  // 导航请求开始时刻
responseEnd:       100.000  // 最后接收字节的高精度时间

如下脚本展示开发者如何使用 PerformanceNavigationTiming 接口获取与文档导航相关的精确时序数据:

<script>
function showNavigationDetails() {
  // 获取首个条目
  const [entry] = performance.getEntriesByType("navigation");
  // 在开发者控制台以表格展示
  console.table(entry.toJSON());
}
</script>
<body onload="showNavigationDetails()">

2. 术语

表达 “一个Foo对象”,如 Foo 实际为接口,有时用于代替更准确的说法 “实现 Foo接口的对象”。

术语当前文档 指的是与Window 对象最新 Document 对象关联的文档。

在整个规范中,所有时间值均以自文档导航开始起的毫秒计。比如,文档导航起始时间为 0。 “当前时间”指从文档导航起至此刻经过的毫秒数。 这一时间定义基于[HR-TIME]规范。

3. 导航时序

3.1. 与PerformanceEntry 接口的关系

PerformanceNavigationTiming 接口扩展了 PerformanceEntry 接口的以下属性:

实现 PerformanceNavigationTiming 的用户代理需要 在 Window 上下文的 supportedEntryTypes 中包含 "navigation"。 这使开发者能够检测是否支持导航计时。

3.2. 与PerformanceResourceTiming接口的关系

PerformanceNavigationTiming 接口扩展了 PerformanceResourceTiming 接口的以下属性:

性能时间线中仅包含当前文档 资源;性能时间线中只有一个 PerformanceNavigationTiming 对象。

3.3. PerformanceNavigationTiming 接口

检查并检索 HTTP 缓存 [RFC9111] 中的内容是 获取过程的一部分。 它由 requestStart、 responseStart 和 responseEnd 属性涵盖。
[Exposed=Window]
interface PerformanceNavigationTiming : PerformanceResourceTiming {
    readonly        attribute DOMHighResTimeStamp  unloadEventStart;
    readonly        attribute DOMHighResTimeStamp  unloadEventEnd;
    readonly        attribute DOMHighResTimeStamp  domInteractive;
    readonly        attribute DOMHighResTimeStamp  domContentLoadedEventStart;
    readonly        attribute DOMHighResTimeStamp  domContentLoadedEventEnd;
    readonly        attribute DOMHighResTimeStamp  domComplete;
    readonly        attribute DOMHighResTimeStamp  loadEventStart;
    readonly        attribute DOMHighResTimeStamp  loadEventEnd;
    readonly        attribute NavigationTimingType type;
    readonly        attribute unsigned short       redirectCount;
    readonly        attribute DOMHighResTimeStamp  criticalCHRestart;
    readonly        attribute NotRestoredReasons?  notRestoredReasons;
    readonly        attribute PerformanceTimingConfidence confidence;
    [Default] object toJSON();
};

一个 PerformanceNavigationTiming 具有关联的 文档加载计时信息 文档加载计时。

一个 PerformanceNavigationTiming 具有关联的 文档卸载计时信息 上一文档卸载计时。

一个 PerformanceNavigationTiming 具有关联的 数值 重定向计数。

一个 PerformanceNavigationTiming 具有关联的 NavigationTimingType 导航类型。

一个 PerformanceNavigationTiming 具有关联的 DOMHighResTimeStamp `Critical-CH` 重启时间。

一个 PerformanceNavigationTiming 具有关联的 NotRestoredReasons 未恢复原因。

一个 PerformanceNavigationTiming 具有关联的 PerformanceTimingConfidence 置信度值。

一个 PerformanceNavigationTiming 具有关联的实数 随机化触发率, 其为由实现定义的。

一个 PerformanceNavigationTiming 具有关联的 PerformanceTimingConfidenceValue 底层置信度值, 其为由实现定义的。

一个 PerformanceNavigationTiming 具有关联的 null 或service worker 计时信息 service worker 计时。

unloadEventStart getter 步骤是返回 this 的 上一文档卸载 计时的 unload 事件开始时间。

如果上一文档与当前文档具有相同的 源,则此时间戳是在 用户代理开始处理上一文档的 unload 事件 之前立即测量的。如果不存在上一文档,或者 上一文档与当前文档具有不同的源,则此 属性将返回 零。

unloadEventEnd 的 getter 步骤是返回 this 的 上一文档卸载 计时的 unload 事件结束时间。

如果上一文档与当前文档具有相同的 源,则此时间戳是在 用户代理完成处理上一文档的 unload 事件 之后立即测量的。如果不存在上一文档,或者 上一文档与当前文档具有不同的源,则此 属性将返回 零。

domInteractive getter 步骤是返回 this 的文档加载计时的 DOM 可交互时间。

此时间戳是在用户代理将 当前文档就绪状态设置为 "interactive" 之前测量的。

domContentLoadedEventStart getter 步骤是返回 this 的 文档加载计时的 DOM 内容加载事件开始时间。

此时间戳是在用户代理分派 DOMContentLoaded 事件之前测量的。

domContentLoadedEventEnd getter 步骤是返回 this 的文档加载计时的 DOM 内容加载事件结束时间。

此时间戳是在用户代理完成处理 DOMContentLoaded 事件之后测量的。

domComplete getter 步骤 是返回 this 的文档加载计时的 DOM 完成时间。

此时间戳是在用户代理将 当前文档就绪状态设置为 "complete" 之前测量的。有关精确 定义,请参阅文档就绪状态。

loadEventStart getter 步骤是返回 this 的文档加载计时的 load 事件开始时间。

此时间戳是在用户代理为文档分派 load 事件之前测量的。

loadEventEnd getter 步骤是返回 this 的文档加载计时的 load 事件结束时间。

此时间戳是在用户代理完成处理文档的 load 事件之后测量的。

type getter 步骤是运行 this 的导航类型。

客户端重定向,例如使用Refresh pragma 指令的重定向,不被本规范视为HTTP 重定向。在这些 情况下,type 属性应该返回适当的值,例如在重新加载 当前页面时返回 reload,或者在 导航到新 URL 时返回 navigate。

redirectCount getter 步骤是返回 this 的 重定向计数。

criticalCHRestart getter 步骤是返回 this 的 `Critical-CH` 重启时间。

如果 criticalCHRestart 不为 0,则它会早于除 navigationStart、unloadEventStart 和 unloadEventEnd 之外的所有其他时间戳。这是因为 它标记了 导航的重定向部分重新开始的时刻。

notRestoredReasons getter 步骤是返回 this 的 未恢复原因。

confidence getter 步骤 是运行以下步骤:

  1. 如果 this 的文档加载计时的 DOM 可交互时间为 0,则返回 null。
  2. 如果 this 的置信度值不为 null, 则返回它。
  3. 令 confidence 为一个新的 PerformanceTimingConfidence 对象,该对象创建于 this 的相关设置对象的相关 realm中。
  4. 将 confidence 的 randomizedTriggerRate 设置为 this 的随机化触发率。
  5. 按照以下算法确定 confidence 的 value:
    1. 令 p 为 confidence 的 randomizedTriggerRate。
    2. 令 underlying 为 this 的底层置信度 值,它是一个 PerformanceTimingConfidenceValue。
    3. 令 r 为从区间 [0, 1) 中均匀随机抽取的一个实数。
    4. 如果 r > 或等于 p,则返回 underlying。
    5. 否则:
      1. 令 s 为从集合 {0, 1} 中均匀随机抽取的一个整数。
      2. 如果 s 等于 0,则返回 high。
      3. 否则,返回 low。
  6. 返回 confidence。

这些值应只设置一次,且在 this 生命周期内不变。

本节旨在帮助 RUM 提供方和开发者解释 confidence。由于 随机触发率在不同记录间会变化, 需按记录加权以获得无偏聚合。下面流程说明如何在统计汇总前,根据 value 加权。

要计算 high 和 low 的无偏均值:

  1. 针对每个记录:
    • 令 p 为记录的 randomizedTriggerRate。
    • 令 c 为记录的 value。
    • 令 R 为 c 是 high 时取1,否则取0。
    • 按 c 计算记录加权 w:
      • 估算 high 均值时:w = (R - (p / 2)) / (1 - p)。
      • 估算 low 均值时: w = ((1 - R) - (p / 2)) / (1 - p)。
      注意部分记录 w 可为负;每条都保留。
    • 令 weighted_duration = duration * w。
  2. 令 total_weighted_duration 为所有记录 weighted_duration 之和。
  3. 令 sum_weights 为所有记录 w 之和。
  4. 若sum_weights不近零,debiased_mean = total_weighted_duration / sum_weights。

要计算 high 和 low 的无偏分位数:

  1. 按均值计算步骤求每条记录加权 w。
  2. 令 sum_weights 为所有记录 w 之和。
  3. 令 sorted_records 为所有记录按 duration 升序排序。
  4. 欲求某分位(0-100),q = percentile / 100.0
  5. 遍历sorted_records,对每条:
    • 计算累计加权 cw: cw = sum_{i: duration_i <= duration_j} w_i。
    • 无偏累计分布函数: cdf = cw / sum_weights
  6. 找到第一个 idx 满足 cdf ≥ q。
    • 如果 idx 为 0,返回 duration ,即 sorted_records[0]。
    • 若无此 idx,返回 duration ,即 sorted_records[n]。
  7. 计算插值比例:
    • 令 lower_cdf 为 sorted_records[idx-1] 的 cdf
    • 令 upper_cdf 为 sorted_records[idx] 的 cdf
    • 若 lower_cdf = upper_cdf,返回 duration ,即 sorted_records[idx]。
    • 否则:
      • ifrac = (q - lower_cdf) / (upper_cdf - lower_cdf)
      • 令 lower_duration 为 duration ,即 sorted_records[idx-1]
      • 令 upper_duration 为 duration ,即 sorted_records[idx]
      • 返回 lower_duration + (upper_duration - lower_duration) * ifrac

toJSON()方法会为this执行默认toJSON步骤。

3.3.1. NavigationTimingType 枚举

enum NavigationTimingType {
    "navigate",
    "reload",
    "back_forward"
};

这些枚举值定义如下:

navigate
导航,其 历史处理行为 被设置为 "default" 或 "replace"。
reload
导航对象 navigable 被 重新加载。
back_forward
从历史记录中应用的导航。

上述枚举值格式与 WebIDL 对枚举值的格式建议不一致。 但由于与已发布实现的兼容性问题,无法修改。[WebIDL]

3.3.2. PerformanceTimingConfidence 接口

[Exposed=Window]
interface PerformanceTimingConfidence {
    readonly attribute double randomizedTriggerRate;
    readonly attribute PerformanceTimingConfidenceValue value;
    object toJSON();
};
randomizedTriggerRate, 类型为 double,只读

此属性必须返回区间 [0, 1) 内的一个实数, 表示在公开置信度 value 时应用噪声的频率。

value, 类型为 PerformanceTimingConfidenceValue, 只读

此属性必须返回一个 PerformanceTimingConfidenceValue。

toJSON()

此方法为 this 运行默认 toJSON 步骤。

3.3.3. PerformanceTimingConfidenceValue 枚举

enum PerformanceTimingConfidenceValue {
  "high",
  "low"
};

这些枚举值定义如下:

high
用户代理认为导航指标能够代表当前用户设备。
low
导航指标可能不能代表当前用户设备。用户代理可能会考虑机器状态或用户配置。

在确定底层置信值时,用户代理 只能基于瞬时运行时条件作出判断,如启动、临时高 CPU 占用、临时内存压力或其他短时情形。

用户代理不得基于设备或配置的永久属性判定底层置信值。 禁止考虑的例子包括物理内存、CPU 核心数、已安装扩展数量等静态环境信息。

置信度旨在反映运行时的可变性,而非系统能力。

4. 流程

4.1. 处理模型

下图展示了 PerformanceNavigationTiming 接口定义的时序属性。带括号的属性代表涉及不同 源文档导航时可能不可用。
Navigation Timing attributes

5. 创建导航时序条目

每个文档都关联一个导航时序条目,初始为未设值。

要为 Document document 创建 导航计时条目, 给定一个获取计时信息 fetchTiming、一个数值 redirectCount、一个 NavigationTimingType navigationType、一个 null 或service worker 计时信息 serviceWorkerTiming、 一个 DOMString cacheMode、一个 DOMHighResTimeStamp criticalCHRestart,以及一个响应正文 信息 bodyInfo,执行以下步骤:

  1. 令 global 为 document 的 相关全局对象。
  2. 令 navigationTimingEntry 为新建的PerformanceNavigationTiming 对象,分配在 global 的 realm 内。
  3. 为 navigationTimingEntry 执行资源时序条目设置,给定 "navigation"、 document 的 URL, fetchTiming、cacheMode 和 bodyInfo。
  4. 设置 navigationTimingEntry 的文档加载时序为document 的加载时序信息
  5. 设置 navigationTimingEntry 的前文档卸载时序 为 document 的前文档卸载时序。
  6. 设置 navigationTimingEntry 的重定向计数 为 redirectCount。
  7. 设置 navigationTimingEntry 的导航类型 为 navigationType。
  8. 设置 navigationTimingEntry 的service worker 时序 为 serviceWorkerTiming。
  9. 设置 document 的 导航时序条目为 navigationTimingEntry。
  10. 设置 navigationTimingEntry 的`Critical-CH` 重启时间 为 criticalCHRestart。
  11. 设置 navigationTimingEntry 的未恢复原因 为用 document 的未恢复原因创建 NotRestoredReasons 对象 的结果。
  12. 将 navigationTimingEntry 加入 global 的 performance entry buffer。

要为 Document document排队导航时序条目, 排队 document 的 导航时序条目。

6. 隐私考量

本节为非规范内容。

6.1. 信息披露

利用精心设计的时序攻击,有泄露终端用户浏览和活动历史的风险。例如,卸载时间揭示了前一页执行其 unload 处理器的时长,可能被用于推测 用户登录状态。这类攻击通过卸载文档时强制执行 同源检测算法得到缓解,详见 HTML 规范。

放宽同源策略不足以阻止对其它文档的未授权访问。在共享托管环境里,不受信第三方可在同一 IP 不同端口部署 HTTP 服务器。

6.2. 跨目录访问

同一主机下不同页面(如用户内容平台中不同作者的页面)被认为属于同源, 因为没有机制可按路径名限制访问。页面间导航允许后续页面访问前一页的时序信息, 包括重定向和卸载事件等相关时序。

7. 安全考量

本节为非规范内容。

PerformanceNavigationTiming 接口会将前一个文档时序信息暴露给当前文档。 为限制包含前文档信息的 PerformanceNavigationTiming 属性的访问, 前文档卸载算法 会强制执行同源策略, 并将相关属性设为零。

7.1. 检测代理服务器

若用户代理与 Web 服务器之间部署有代理, connectStart 到 connectEnd 的时间间隔反映用户代理与代理之间的延迟,而非 Web 服务器。 因此,Web 服务器有可能推断出代理的存在。对于 SOCKS 代理,该时间段还包含代理认证以及代理到 Web 服务器连接时间,这对代理探测有干扰。 若为 HTTP 代理,用户代理甚至可能完全无感知,因此无法总能防止该类攻击。

8. 废弃内容

本节定义了 [NAVIGATION-TIMING] 第一版中引入的属性和接口,仅为兼容性保留。作者不应再使用下列接口,强烈建议改用新的 PerformanceNavigationTiming 接口——参见变更及改进摘要。

8.1. PerformanceTiming 接口

[Exposed=Window]
interface PerformanceTiming {
  readonly attribute unsigned long long navigationStart;
  readonly attribute unsigned long long unloadEventStart;
  readonly attribute unsigned long long unloadEventEnd;
  readonly attribute unsigned long long redirectStart;
  readonly attribute unsigned long long redirectEnd;
  readonly attribute unsigned long long fetchStart;
  readonly attribute unsigned long long domainLookupStart;
  readonly attribute unsigned long long domainLookupEnd;
  readonly attribute unsigned long long connectStart;
  readonly attribute unsigned long long connectEnd;
  readonly attribute unsigned long long secureConnectionStart;
  readonly attribute unsigned long long requestStart;
  readonly attribute unsigned long long responseStart;
  readonly attribute unsigned long long responseEnd;
  readonly attribute unsigned long long domLoading;
  readonly attribute unsigned long long domInteractive;
  readonly attribute unsigned long long domContentLoadedEventStart;
  readonly attribute unsigned long long domContentLoadedEventEnd;
  readonly attribute unsigned long long domComplete;
  readonly attribute unsigned long long loadEventStart;
  readonly attribute unsigned long long loadEventEnd;
  [Default] object toJSON();
};

本节定义的所有时间值均以自 起的毫秒数计。

navigationStart

此属性必须返回用户 代理完成对上一文档提示 卸载之后立即的时间。如果没有上一 文档,则此属性必须返回当前 文档被创建的时间。

此属性未为 PerformanceNavigationTiming 定义。作为替代,作者可以使用 timeOrigin 来获取等效的时间戳。

unloadEventStart

如果上一文档和当前文档具有相同的 源,则此 属性 必须返回用户代理开始上一文档的 unload 事件 之前立即的时间。如果没有上一文档,或者 上一文档与当前文档具有不同的源,则此 属性必须返回零。

unloadEventEnd

如果上一文档和当前文档 同源,则此 属性 必须返回用户代理完成上一文档的 unload 事件 之后立即的时间。如果没有上一文档,或者 上一文档与当前文档具有不同的源,或者 unload 尚未完成,则此属性必须返回零。

如果导航时存在HTTP 重定向,且并非所有重定向都来自 同一个源,则 unloadEventStart 和 unloadEventEnd 都必须返回零。

redirectStart

如果导航时存在HTTP 重定向,并且所有重定向都来自 同一个源,则此 属性必须返回发起该重定向的 获取开始时间。 否则,此属性必须 返回零。

redirectEnd

如果导航时存在HTTP 重定向,并且所有重定向都来自同一个 源,则此 属性 必须返回收到最后一次重定向响应的最后一个字节 之后立即的时间。否则,此属性必须 返回零。

fetchStart

如果要使用 "GET" 获取新资源 请求 方法,fetchStart 必须返回用户代理开始检查 HTTP 缓存 [RFC9111] 之前立即的时间。否则,它必须 返回 用户代理开始获取该 资源的时间。

domainLookupStart

此属性必须返回用户 代理开始对当前文档进行域名查找之前立即的时间。如果 使用了持久 连接 [RFC9112],或者 当前文档是从 HTTP 缓存 [RFC9111] 或本地资源中检索的, 则此属性必须返回与 fetchStart 相同的值。

domainLookupEnd

此属性必须返回用户 代理完成对当前文档的域名查找之后立即的时间。 如果使用了持久 连接 [RFC9112],或者 当前文档是从 HTTP 缓存 [RFC9111] 或本地资源中检索的, 则此属性必须返回与 fetchStart 相同的值。

检查并检索 HTTP 缓存 [RFC9111] 中的内容是 获取过程的一部分。它由 requestStart、 responseStart 和 responseEnd 属性涵盖。

如果用户代理已经在缓存中拥有域信息, 则 domainLookupStart 和 domainLookupEnd 表示 用户代理从缓存中开始和结束检索域数据的 时间。

connectStart

此属性必须返回用户 代理开始建立到服务器的连接以检索 文档之前立即的时间。如果使用了持久 连接 [RFC9112],或者当前文档是 从 HTTP 缓存 [RFC9111] 或 本地资源中检索的,则此属性必须返回 domainLookupEnd 的值。

connectEnd

此属性必须返回用户 代理完成建立到服务器的连接以 检索当前文档之后立即的时间。如果使用了 持久连接 [RFC9112],或者 当前文档是从 HTTP 缓存 [RFC9111] 或本地资源中检索的, 则此属性必须返回 domainLookupEnd 的值。

如果传输连接失败,并且用户代理重新打开 连接,则 connectStart 和 connectEnd 应返回新连接相应的 值。

connectEnd 必须包括建立传输连接所需的时间间隔, 以及其他时间 间隔,例如 SSL 握手和 SOCKS 身份验证。

secureConnectionStart

此属性是可选的。无法提供此 属性的用户代理必须将其设置为 undefined。当此属性 可用时,如果当前页面的方案 [URL] 为 "https",则此属性必须返回 用户代理开始用于保护当前连接的握手过程之前立即的时间。 如果此属性可用但未使用 HTTPS, 则此属性必须返回零。

requestStart

此属性必须返回用户 代理开始从服务器、或 HTTP 缓存 [RFC9111] 或本地 资源请求当前文档之前立即的时间。

如果发送请求后传输连接失败,并且 用户代理重新打开连接并重新发送请求, requestStart 应返回新请求相应的 值。

此接口不包含用于表示 请求发送完成的属性,例如 requestEnd。

  • 用户代理完成发送请求 并不总是表示网络传输中相应的完成时间, 而后者正是拥有此类属性的大部分价值 所在。
  • 由于 HTTP 层 封装,一些用户代理确定请求实际 发送完成时间的成本很高。
responseStart

此属性必须返回用户 代理从服务器、或 HTTP 缓存 [RFC9111] 或本地 资源收到响应的第一个字节之后立即的时间。

responseEnd

此属性必须返回用户 代理收到当前文档的最后一个字节之后立即的时间,或者 传输连接关闭之前立即的时间,以 较早发生者为准。此处的文档可以从 服务器、HTTP 缓存 [RFC9111] 或 本地资源中接收。

domLoading

此属性必须返回用户 代理将当前文档 就绪状态设置为 "loading" 之前立即的时间。

由于现有用户代理创建 Document 对象的时机 存在差异, domLoading 返回的值由实现决定,不应 用于有意义的度量指标。

domInteractive

此属性必须返回用户 代理将当前文档 就绪状态设置为 "interactive" 之前立即的时间。

domContentLoadedEventStart

此属性必须返回用户 代理在 Document 上触发 DOMContentLoaded 事件之前立即的时间。

domContentLoadedEventEnd

此属性必须返回 文档的 DOMContentLoaded 事件完成之后立即的时间。

domComplete

此属性必须返回用户 代理将当前文档 就绪状态设置为 "complete" 之前立即的时间。

如果当前文档 就绪状态多次更改为相同状态, domLoading、 domInteractive、 domContentLoadedEventStart、 domContentLoadedEventEnd 和 domComplete 必须返回相应文档就绪状态 首次发生更改的时间。

loadEventStart

此属性必须返回当前文档的 load 事件被触发之前立即的时间。当 load 事件尚未触发时,它必须返回零。

loadEventEnd

此属性必须返回当前文档的 load 事件 完成的时间。当 load 事件尚未触发或尚未完成时,它必须返回零。

toJSON()
为 this 运行默认 toJSON 步骤。

8.2. PerformanceNavigation 接口

[Exposed=Window]
interface PerformanceNavigation {
  const unsigned short TYPE_NAVIGATE = 0;
  const unsigned short TYPE_RELOAD = 1;
  const unsigned short TYPE_BACK_FORWARD = 2;
  const unsigned short TYPE_RESERVED = 255;
  readonly attribute unsigned short type;
  readonly attribute unsigned short redirectCount;
  [Default] object toJSON();
};
TYPE_NAVIGATE

历史记录处理行为 被设置为 "default" 或 "replace" 的导航。

TYPE_RELOAD

历史记录处理行为 被设置为 "reload" 的导航。

TYPE_BACK_FORWARD

历史记录处理行为 被设置为 "entry update" 的导航。

TYPE_RESERVED

上述值未定义的任何导航类型。

type

此属性必须返回上一次非重定向 导航的类型。 它必须具有以下 导航类型 值之一。

客户端重定向,例如使用Refresh pragma 指令的重定向,不被本规范视为HTTP 重定向。在这些 情况下,type 属性应该返回适当的值,例如 重新加载当前页面时返回 TYPE_RELOAD,或者 导航到新 URL 时返回 TYPE_NAVIGATE。

redirectCount

此属性必须返回自上一次 非重定向导航以来的重定向次数。如果没有重定向,或者存在任何 与 目标文档 不同源的 重定向,则此属性必须返回零。

toJSON()
为 this 运行默认 toJSON 步骤。

8.3. 对 Performance 接口的扩展

[Exposed=Window]
partial interface Performance {
  [SameObject]
  readonly attribute PerformanceTiming timing;
  [SameObject]
  readonly attribute PerformanceNavigation navigation;
};

Performance 接口定义见 [PERFORMANCE-TIMELINE-2]。

timing

timing 属性表示自上次非重定向导航以来的时序信息。 该属性由 PerformanceTiming 接口定义。

navigation

navigation 属性由 PerformanceNavigation 接口定义。

9. 致谢

感谢 Anne Van Kesteren、Arvind Jain、Boris Zbarsky、Jason Weber、 Jonas Sicking、James Simonsen、Karen Anderson、Nic Jansma、Philippe Le Hegaret、Steve Souders、Todd Reifsteck、Tony Gentilcore、William Chan 和 Zhiheng Wang 对本规范的贡献。

一致性

文档约定

一致性要求通过描述性断言与 RFC 2119 专用术语结合表述。 在本规范的规范性部分中, “MUST”、“MUST NOT”、“REQUIRED”、“SHALL”、“SHALL NOT”、“SHOULD”、“SHOULD NOT”、“RECOMMENDED”、“MAY”、“OPTIONAL” 等关键词, 均按照 RFC 2119 规定的含义解读。 但为提升可读性, 本规范并未将这些词全部用大写表示。

除明确标注为非规范性、示例和注释的章节外, 本规范所有内容均为规范性内容。[RFC2119]

本规范中的示例通常以“例如”引出, 或以 class="example" 与规范性文本区分, 如下所示:

这是个信息型示例。

信息性注释以“注”字开头, 并使用 class="note" 与规范内容区分, 如下所示:

注,这是一个信息性注释。

一致性算法

对于算法部分通过祈使语气表述的要求 (如“去除所有前导空格”或“返回 false 并中止这些步骤”), 均应配合引入算法时的关键词 (如“must”、“should”、“may”等)共同理解。

以算法或具体步骤表述的一致性要求, 只要结果等价,可用任意方式实现。 本规范中定义的算法主要为易于理解, 并不要求高性能。 鼓励实现者进行优化。

索引

本规范定义的术语

引用规范中定义的术语

参考文献

规范性引用

[DOM]
Anne van Kesteren. DOM 标准. 现行标准. URL: https://dom.spec.whatwg.org/
[FETCH]
Anne van Kesteren. Fetch 标准. 现行 标准. URL: https://fetch.spec.whatwg.org/
[HR-TIME]
Yoav Weiss. 高精度时间. 2026 年 3 月 24 日. WD. URL: https://www.w3.org/TR/hr-time-3/
[HTML]
Anne van Kesteren; et al. HTML 标准. 现行标准. URL: https://html.spec.whatwg.org/multipage/
[INFRA]
Anne van Kesteren; Domenic Denicola. Infra 标准. 现行标准. URL: https://infra.spec.whatwg.org/
[PERFORMANCE-TIMELINE-2]
Nicolas Pena Moreno. 性能 时间线. 2025 年 5 月 21 日. CRD. URL: https://www.w3.org/TR/performance-timeline/
[RESOURCE-TIMING-2]
Yoav Weiss; Noam Rosenthal. 资源 计时. 2026 年 4 月 20 日. CRD. URL: https://www.w3.org/TR/resource-timing/
[RFC2119]
S. Bradner. 用于 RFC 中表示 要求级别的关键词. 1997 年 3 月. 当前最佳实践. URL: https://datatracker.ietf.org/doc/html/rfc2119
[RFC9111]
R. Fielding, Ed.; M. Nottingham, Ed.; J. Reschke, Ed.. HTTP 缓存. 2022 年 6 月. 互联网 标准. URL: https://httpwg.org/specs/rfc9111.html
[RFC9112]
R. Fielding, Ed.; M. Nottingham, Ed.; J. Reschke, Ed.. HTTP/1.1. 2022 年 6 月. 互联网标准. URL: https://httpwg.org/specs/rfc9112.html
[SERVICE-WORKERS]
Monica CHINTALA; Yoshisato Yanagisawa. Service Workers 每夜版. 2026 年 8 月 12 日. CRD. URL: https://www.w3.org/TR/service-workers/
[URL]
Anne van Kesteren. URL 标准. 现行标准. URL: https://url.spec.whatwg.org/
[WebIDL]
Edgar Chen; Timothy Gu. Web IDL 标准. 现行 标准. URL: https://webidl.spec.whatwg.org/

非规范性引用

[HR-TIME-2]
Ilya Grigorik. 高精度时间第 2 级. 2019 年 11 月 21 日. REC. URL: https://www.w3.org/TR/hr-time-2/
[JSMEASURE]
Ramakrishnan Rajamony; Mootaz Elnozahy. 测量 WWW 上客户端感知的响应时间. 2001 年 3 月. 第 3 届 USENIX 互联网技术与系统研讨会(USITS)论文集. URL: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.69.7329&rep=rep1&type=pdf
[NAVIGATION-TIMING]
Zhiheng Wang. 导航计时. 2012 年 12 月 17 日. REC. URL: https://www.w3.org/TR/navigation-timing/

IDL 索引

[Exposed=Window]
interface PerformanceNavigationTiming : PerformanceResourceTiming {
    readonly        attribute DOMHighResTimeStamp  unloadEventStart;
    readonly        attribute DOMHighResTimeStamp  unloadEventEnd;
    readonly        attribute DOMHighResTimeStamp  domInteractive;
    readonly        attribute DOMHighResTimeStamp  domContentLoadedEventStart;
    readonly        attribute DOMHighResTimeStamp  domContentLoadedEventEnd;
    readonly        attribute DOMHighResTimeStamp  domComplete;
    readonly        attribute DOMHighResTimeStamp  loadEventStart;
    readonly        attribute DOMHighResTimeStamp  loadEventEnd;
    readonly        attribute NavigationTimingType type;
    readonly        attribute unsigned short       redirectCount;
    readonly        attribute DOMHighResTimeStamp  criticalCHRestart;
    readonly        attribute NotRestoredReasons?  notRestoredReasons;
    readonly        attribute PerformanceTimingConfidence confidence;
    [Default] object toJSON();
};

enum NavigationTimingType {
    "navigate",
    "reload",
    "back_forward"
};

[Exposed=Window]
interface PerformanceTimingConfidence {
    readonly attribute double randomizedTriggerRate;
    readonly attribute PerformanceTimingConfidenceValue value;
    object toJSON();
};

enum PerformanceTimingConfidenceValue {
  "high",
  "low"
};

[Exposed=Window]
interface PerformanceTiming {
  readonly attribute unsigned long long navigationStart;
  readonly attribute unsigned long long unloadEventStart;
  readonly attribute unsigned long long unloadEventEnd;
  readonly attribute unsigned long long redirectStart;
  readonly attribute unsigned long long redirectEnd;
  readonly attribute unsigned long long fetchStart;
  readonly attribute unsigned long long domainLookupStart;
  readonly attribute unsigned long long domainLookupEnd;
  readonly attribute unsigned long long connectStart;
  readonly attribute unsigned long long connectEnd;
  readonly attribute unsigned long long secureConnectionStart;
  readonly attribute unsigned long long requestStart;
  readonly attribute unsigned long long responseStart;
  readonly attribute unsigned long long responseEnd;
  readonly attribute unsigned long long domLoading;
  readonly attribute unsigned long long domInteractive;
  readonly attribute unsigned long long domContentLoadedEventStart;
  readonly attribute unsigned long long domContentLoadedEventEnd;
  readonly attribute unsigned long long domComplete;
  readonly attribute unsigned long long loadEventStart;
  readonly attribute unsigned long long loadEventEnd;
  [Default] object toJSON();
};

[Exposed=Window]
interface PerformanceNavigation {
  const unsigned short TYPE_NAVIGATE = 0;
  const unsigned short TYPE_RELOAD = 1;
  const unsigned short TYPE_BACK_FORWARD = 2;
  const unsigned short TYPE_RESERVED = 255;
  readonly attribute unsigned short type;
  readonly attribute unsigned short redirectCount;
  [Default] object toJSON();
};

[Exposed=Window]
partial interface Performance {
  [SameObject]
  readonly attribute PerformanceTiming timing;
  [SameObject]
  readonly attribute PerformanceNavigation navigation;
};