A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.cdn.mozilla.net/en-US/docs/Web/API/PerformanceEventTiming/interactionId below:

PerformanceEventTiming: interactionId property - Web APIs

PerformanceEventTiming: interactionId property

Limited availability

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The read-only interactionId property returns an ID that uniquely identifies a user interaction which triggered a series of associated events.

Description

When a user interacts with a web page, a user interaction (for example a click) usually triggers a sequence of events, such as pointerdown, pointerup, and click events. To measure the latency of this series of events, the events share the same interactionId.

An interactionId is only computed for the following event types belonging to a user interaction. It is 0 otherwise.

Value

A number.

Examples Using interactionId

The following example collects event duration for all events corresponding to an interaction. The eventLatencies map can then be used to find events with maximum duration for a user interaction, for example.

// The key is the interaction ID.
let eventLatencies = {};

const observer = new PerformanceObserver((list) => {
  list.getEntries().forEach((entry) => {
    if (entry.interactionId > 0) {
      const interactionId = entry.interactionId;
      if (!eventLatencies.has(interactionId)) {
        eventLatencies[interactionId] = [];
      }
      eventLatencies[interactionId].push(entry.duration);
    }
  });
});

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

// Log events with maximum event duration for a user interaction
Object.entries(eventLatencies).forEach(([k, v]) => {
  console.log(Math.max(...v));
});
Specifications Browser compatibility

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4