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

Performance: interactionCount property

· 52CE 我爱测

The read-only `performance.interactionCount` property represents the number of real-user interactions that have occurred on the page since it was loaded.

Performance API

The read-only performance.interactionCount property represents the number of real-user interactions that have occurred on the page since it was loaded.

Only discrete interactions with an PerformanceEventTiming.interactionId — such as clicks and key events — are counted. Other interactions, such as scroll interactions, are excluded.

This is useful when calculating Interaction_to_next_paint, and in particular to exclude outliers for long-lived pages. INP takes the 98th percentile of interactions for a page and so excludes 1 in every 50 interactions as "outliers" that are not reflective of overall page responsiveness.

Value

A number, which is initially 0, and increments by 1 with each discrete interaction as measured by PerformanceEventTiming, where an PerformanceEventTiming.interactionId is assigned.

Examples

Checking the number of interactions to accurately calculate INP

For pages with a large number of interactions, you can recalculate INP after excluding 1 out of every 50 outliers using the following pattern:

if (performance.interactionCount >= 50) {
  recalculateINP(); // Actual calculation is complex and is not shown here
}

Specifications

Browser compatibility

See also

  • PerformanceEventTiming
  • PerformanceEventTiming.interactionId
  • Interaction_to_next_paint

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

资料来源与适用范围

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

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

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