This feature is not Baseline because it does not work in some of the most widely-used browsers.
The EventCounts interface of the Performance API provides the number of events that have been dispatched for each event type.
An EventCounts instance is a read-only Map-like object, in which each key is the name string for an event type, and the corresponding value is an integer indicating the number of events that have been dispatched for that event type.
This interface has no constructor. You typically get an instance of this object using the performance.eventCounts property.
sizeSee Map.prototype.size for details.
entries()See Map.prototype.entries() for details.
forEach()See Map.prototype.forEach() for details.
get()See Map.prototype.get() for details.
has()See Map.prototype.has() for details.
keys()See Map.prototype.keys() for details.
values()See Map.prototype.values() for details.
Below are a few examples to get information from an EventCounts map. Note that the map is read-only and the clear(), delete(), and set() methods aren't available.
for (entry of performance.eventCounts.entries()) {
const type = entry[0];
const count = entry[1];
}
const clickCount = performance.eventCounts.get("click");
const isExposed = performance.eventCounts.has("mousemove");
const exposedEventsCount = performance.eventCounts.size;
const exposedEventsList = [...performance.eventCounts.keys()];
| Specification |
|---|
| Event Timing API> # sec-event-counts> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
@@iterator |
85 | 85 | 89 | 71 | No | 85 | 89 | 60 | No | 14.0 | 85 | No |
EventCounts |
85 | 85 | 89 | 71 | No | 85 | 89 | 60 | No | 14.0 | 85 | No |
entries |
85 | 85 | 89 | 71 | No | 85 | 89 | 60 | No | 14.0 | 85 | No |
forEach |
85 | 85 | 89 | 71 | No | 85 | 89 | 60 | No | 14.0 | 85 | No |
get |
85 | 85 | 89 | 71 | No | 85 | 89 | 60 | No | 14.0 | 85 | No |
has |
85 | 85 | 89 | 71 | No | 85 | 89 | 60 | No | 14.0 | 85 | No |
keys |
85 | 85 | 89 | 71 | No | 85 | 89 | 60 | No | 14.0 | 85 | No |
size |
85 | 85 | 89 | 71 | No | 85 | 89 | 60 | No | 14.0 | 85 | No |
values |
85 | 85 | 89 | 71 | No | 85 | 89 | 60 | No | 14.0 | 85 | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/EventCounts