导航时序 第二级

W3C 工作草案,

关于本文件的更多详情
当前版本:
https://www.w3.org/TR/2026/WD-navigation-timing-2-20260225/
最新发布版本:
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 的用户代理需在 "navigation" 加入 supportedEntryTypes ,用于 Window 上下文。这允许开发者检测导航时序支持。

3.2. PerformanceResourceTiming接口的关系

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

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

3.3. PerformanceNavigationTiming 接口

检查和获取 HTTP 缓存 [RFC7234] 内容 是获取流程的一部分。 它由 requestStartresponseStartresponseEnd 等属性涵盖。
[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获取器步骤为返回 this前文档卸载时序unload 事件起始时间

如果前一个文档和当前文档具有相同 ,此时间戳在 用户代理触发前文档unload 事件之前立即测量。若没有前文档或源不同,则返回 0。

unloadEventEnd 获取器步骤为返回 this前文档卸载时序unload 事件结束时间

如果前一个文档和当前文档具有相同 ,此时间戳在 用户代理处理前文档unload 事件后立即测量。若没有前文档或源不同,则返回 0。

domInteractive获取器步骤为返回 this文档加载时序DOM interactive 时间

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

domContentLoadedEventStart获取器步骤为返回this文档加载时序DOM content loaded 事件起始时间

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

domContentLoadedEventEnd获取器步骤为返回 this文档加载时序DOM content loaded 事件结束时间

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

domComplete获取器步骤为返回 this文档加载时序DOM complete 时间

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

loadEventStart获取器步骤为返回 this文档加载时序load 事件起始时间

此时间戳在用户代理分发文档 load事件前测量。

loadEventEnd获取器步骤为返回 this文档加载时序load 事件结束时间

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

type获取器步骤为运行 this导航类型

客户端重定向,如 Refresh pragma 指令,在本规范中不算作 HTTP 重定向。这种情况下, type 属性应返回适当值,如当前页重新加载则 reload,新 URL 导航则 navigate

redirectCount获取器步骤为返回 this重定向计数

criticalCHRestart获取器步骤为返回 this`Critical-CH` 重启时间

如果 criticalCHRestart 不为 0,则它将在所有其他时间戳之前, 除 navigationStartunloadEventStartunloadEventEnd。 因为它标记了重定向部分重新启动的时刻。

notRestoredReasons获取器步骤为返回 this未恢复原因

confidence获取器步骤为执行下述步骤:

  1. this文档加载时序DOM interactive 时间为 0,返回 null。
  2. this置信值不为 null, 则返回它。
  3. confidence 为新建 PerformanceTimingConfidence 对象, 在this相关设置对象相关域中创建。
  4. 设置 confidencerandomizedTriggerRatethis随机触发率
  5. 设置 confidencevalue ,遵循如下算法:
    1. pconfidencerandomizedTriggerRate
    2. underlyingthis底层置信值, 一个 PerformanceTimingConfidenceValue
    3. r 为 [0, 1) 区间均匀随机抽选的实数。
    4. 如果 rp,返回 underlying
    5. 否则:
      1. s 为集合 {0, 1} 中均匀随机抽选的整数。
      2. s 等于 0,返回 high
      3. 否则,返回 low
  6. 返回 confidence

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

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

要计算 highlow 的无偏均值:

  1. 针对每个记录:
    • p 为记录的 randomizedTriggerRate
    • c 为记录的 value
    • Rchigh 时取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

要计算 highlow 的无偏分位数:

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

该属性返回 [0, 1) 区间内的实数,表示暴露 置信 value 时施加扰动的概率。

value

该属性返回 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 创建导航时序条目, 给定 fetch 时序信息 fetchTiming、数字 redirectCountNavigationTimingType navigationType,null 或 service worker 时序信息 serviceWorkerTiming、 DOMString cacheModeDOMHighResTimeStamp criticalCHRestart,以及 响应体信息 bodyInfo,依次执行:

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

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

6. 隐私考量

本节为非规范内容。

6.1. 信息披露

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

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

6.2. 跨目录访问

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

7. 安全考量

本节为非规范内容。

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

7.1. 检测代理服务器

若用户代理与 Web 服务器之间部署有代理, connectStartconnectEnd 的时间间隔反映用户代理与代理之间的延迟,而非 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事件前的时间。 若无前文档或前文档非同源,则返回0。

unloadEventEnd

如果前一个文档和当前文档同 , 则返回用户代理完成前文档 unload事件处理后的时间。 若无前文档,源不同或卸载未完成,则返回0。

若导航发生HTTP 重定向且并非所有重定向都来自同一 unloadEventStartunloadEventEnd 必须返回0。

redirectStart

若导航发生HTTP 重定向且所有重定向均来自同一 , 返回发起重定向的fetch 操作起始时间,否则返回0。

redirectEnd

若导航发生HTTP 重定向且所有重定向均来自同一 , 返回收到最后一次重定向响应最后一个字节后的时间,否则返回0。

fetchStart

若新资源通过 "GET" 请求方法 获取, fetchStart 返回用户代理开始检查 HTTP 缓存 前的时刻;否则返回开始获取资源的时间。

domainLookupStart

返回用户代理开始对当前文档进行域名解析前的时刻。 若使用持久连接、或文档来自 HTTP 缓存 或本地资源,返回 fetchStart 的值。

domainLookupEnd

返回用户代理完成当前文档域名解析后的时刻。 若使用持久连接、或文档来自 HTTP 缓存 或本地资源,返回 fetchStart 的值。

检查与获取 HTTP 缓存内容也是获取流程的一部分。 由 requestStartresponseStartresponseEnd 覆盖。

若用户代理已在缓存中拥有域名信息,domainLookupStart 和 domainLookupEnd 分别为开始和结束从缓存获取域名数据的时刻。

connectStart

返回用户代理开始与服务器建立连接以获取文档前的时刻。 若使用持久连接、文档来自 HTTP 缓存 或本地资源,返回 domainLookupEnd 的值。

connectEnd

返回用户代理完成与服务器建立连接,获取文档后的时刻。 若使用持久连接、文档来自 HTTP 缓存 或本地资源,返回 domainLookupEnd 的值。

如果传输连接失败,用户代理重新建立连接,则 connectStartconnectEnd 应返回新连接的值。

connectEnd 包括建立传输连接的耗时,以及SSL握手、SOCKS认证等其它流程耗时。

secureConnectionStart

该属性为可选。用户代理不支持时必须将其设为 undefined。若属性可用,且当前页的scheme [URL]为 "https",则返回 启动安全连接握手前的时刻。若可用但未用 HTTPS,则返回0。

requestStart

返回用户代理向服务器、HTTP 缓存 或本地资源请求当前文档前的时刻。

若请求已发出后连接失败,用户代理重新建立连接并重发请求, requestStart 应返回新请求值。

本接口未包含表示请求发送完成(如 requestEnd)的属性。

  • 用户代理请求发送完成并不总能表示网络传输已结束, 拥有该属性的意义有限。
  • 某些用户代理因 HTTP 层封装,确定请求实际完成时间成本较高。
responseStart

返回用户代理收到服务器、HTTP 缓存 或本地资源首字节响应后的时刻。

responseEnd

返回用户代理收到当前文档最后一个字节或传输连接关闭前的时刻,二者以先到为准。 文档可来源于服务器、HTTP 缓存或本地资源。

domLoading

返回用户代理将当前文档就绪状态设置为 "loading"前的时刻。

由于不同用户代理创建 Document 对象的时机不同,domLoading 返回值具有实现依赖性,不应作为有效指标使用。

domInteractive

返回用户代理将当前文档就绪状态设置为 "interactive"前的时刻。

domContentLoadedEventStart

返回用户代理在 Document 上触发DOMContentLoaded 事件 前的时刻。

domContentLoadedEventEnd

返回文档DOMContentLoaded 事件完成后的时刻。

domComplete

返回用户代理将当前文档就绪状态设置为 "complete"前的时刻。

当前文档就绪状态 多次变为同一值, domLoadingdomInteractivedomContentLoadedEventStartdomContentLoadedEventEnddomComplete 均返回首次对应文档就绪状态变更的时间。

loadEventStart

返回当前文档 load 事件触发前的时刻。尚未触发时返回0。

loadEventEnd

返回当前文档 load 事件完成时的时间。尚未触发或未完成时返回0。

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

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

该属性返回上一次非重定向 导航的类型。 其值只可能为下列 navigation type 定义之一。

客户端重定向(如 Refresh 指令)不属于本规范下的HTTP 重定向。这类情形下,type 属性返回合适值,如当前页刷新用 TYPE_RELOAD,新 URL 导航用 TYPE_NAVIGATE

redirectCount

该属性返回自上次非重定向导航以来的重定向次数。若无重定向,或有任何重定向非目标文档同源,返回0。

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

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 Standard. Living Standard. URL: https://dom.spec.whatwg.org/
[FETCH]
Anne van Kesteren. Fetch Standard. Living Standard. URL: https://fetch.spec.whatwg.org/
[HR-TIME]
Yoav Weiss. High Resolution Time. 2024年11月7日. WD. URL: https://www.w3.org/TR/hr-time-3/
[HTML]
Anne van Kesteren; et al. HTML Standard. Living Standard. URL: https://html.spec.whatwg.org/multipage/
[INFRA]
Anne van Kesteren; Domenic Denicola. Infra Standard. Living Standard. URL: https://infra.spec.whatwg.org/
[PERFORMANCE-TIMELINE-2]
Nicolas Pena Moreno. Performance Timeline. 2025年5月21日. CRD. URL: https://www.w3.org/TR/performance-timeline/
[RESOURCE-TIMING-2]
Yoav Weiss; Noam Rosenthal. Resource Timing. 2026年2月17日. CRD. URL: https://www.w3.org/TR/resource-timing/
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. 1997年3月. Best Current Practice. URL: https://datatracker.ietf.org/doc/html/rfc2119
[SERVICE-WORKERS]
Monica CHINTALA; Yoshisato Yanagisawa. Service Workers Nightly. 2026年2月23日. CRD. URL: https://www.w3.org/TR/service-workers/
[URL]
Anne van Kesteren. URL Standard. Living Standard. URL: https://url.spec.whatwg.org/
[WebIDL]
Edgar Chen; Timothy Gu. Web IDL Standard. Living Standard. URL: https://webidl.spec.whatwg.org/

非规范性引用

[HR-TIME-2]
Ilya Grigorik. High Resolution Time Level 2. 2019年11月21日. REC. URL: https://www.w3.org/TR/hr-time-2/
[JSMEASURE]
Ramakrishnan Rajamony; Mootaz Elnozahy. Measuring Client-Perceived Response Times on the WWW. 2001年3月. 3rd USENIX Symposium on Internet Technologies and Systems (USITS) 论文集. URL: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.69.7329&rep=rep1&type=pdf
[NAVIGATION-TIMING]
Zhiheng Wang. Navigation Timing. 2012年12月17日. REC. URL: https://www.w3.org/TR/navigation-timing/
[RFC2616]
R. Fielding; et al. Hypertext Transfer Protocol -- HTTP/1.1. 1999年6月. Draft Standard. URL: https://www.rfc-editor.org/rfc/rfc2616
[RFC7234]
R. Fielding, Ed.; M. Nottingham, Ed.; J. Reschke, Ed.. Hypertext Transfer Protocol (HTTP/1.1): Caching. 2014年6月. Proposed Standard. URL: https://httpwg.org/specs/rfc7234.html

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;
};