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

PerformanceNavigationTiming: type property

· 52CE 我爱测

The **`type`** read-only property returns the type of navigation.

Performance API

The type read-only property returns the type of navigation.

You can use this property to categorize your navigation timing data as each of these types will have different performance characteristics. Users going back and forth might experience a faster site than users performing navigation for the first time or submitting forms, etc.

For example, if your site provides new content frequently, you might want to refresh that content using Fetch or similar and avoid users having to hit reload for the entire page all the time. The "reload" type can help you find pages that are reloaded frequently.

Value

The type property can have the following values:

  • "navigate"
    • : Navigation started by clicking a link, entering the URL in the browser's address bar, form submission, or initializing through a script operation other than reload and back_forward as listed below.
  • "reload"
    • : Navigation is through the browser's reload operation, location.reload() or a Refresh pragma directive like <meta http-equiv="refresh" content="300">.
  • "back_forward"
    • : Navigation is through the browser's history traversal operation.

Examples

Logging reload navigation

The type property can be used to check whether the navigation was of type reload. You could collect these reload entries in a server-side endpoint to determine which pages of your site gets reloaded the most, or collect all navigation types and determine what percent of users go back and forward, for example.

Example using a PerformanceObserver, which notifies of new navigation 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) => {
    if (entry.type === "reload") {
      console.log(`${entry.name} was reloaded!`);
      console.log(entry);
    }
  });
});

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

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

const entries = performance.getEntriesByType("navigation");
entries.forEach((entry) => {
  if (entry.type === "reload") {
    console.log(`${entry.name} was reloaded!`);
    console.log(entry);
  }
});

Specifications

Browser compatibility

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

资料来源与适用范围

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

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

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