GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||
GeezerVison is showing developer.mozilla.org — PerformanceEventTiming - Web APIs | MDN PerformanceEventTiming
|
| Click events |
auxclick,
click,
contextmenu,
dblclick
|
|---|---|
| Composition events |
compositionend,
compositionstart,
compositionupdate
|
| Drag & drop events |
dragend,
dragenter,
dragleave,
dragover,
dragstart,
drop
|
| Input events |
beforeinput,
input
|
| Keyboard events |
keydown,
keypress,
keyup
|
| Mouse events |
mousedown,
mouseenter,
mouseleave,
mouseout,
mouseover,
mouseup
|
| Pointer events |
pointerover,
pointerenter,
pointerdown,
pointerup,
pointercancel,
pointerout,
pointerleave,
gotpointercapture,
lostpointercapture
|
| Touch events |
touchstart,
touchend,
touchcancel
|
Note that the following events are not included in the list because they are continuous events and no meaningful event counts or performance metrics can be obtained at this point: mousemove, pointermove,
pointerrawupdate, touchmove, wheel, drag.
To get a list of all exposed events, you can also look up keys in the performance.eventCounts map:
const exposedEventsList = [...performance.eventCounts.keys()];
To get event timing information, create a PerformanceObserver instance and then call its observe() method, passing in "event" or "first-input" as the value of the type option. You also need to set buffered to true to get access to events the user agent buffered while constructing the document. The PerformanceObserver object's callback will then be called with a list of PerformanceEventTiming objects which you can analyze.
const observer = new PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
// Full duration
const duration = entry.duration;
// Input delay (before processing event)
const delay = entry.processingStart - entry.startTime;
// Synchronous event processing time
// (between start and end dispatch)
const eventHandlerTime = entry.processingEnd - entry.processingStart;
console.log(`Total duration: ${duration}`);
console.log(`Event delay: ${delay}`);
console.log(`Event handler duration: ${eventHandlerTime}`);
});
});
// Register the observer for events
observer.observe({ type: "event", buffered: true });
You can also set a different durationThreshold. The default is 104ms and the minimum possible duration threshold is 16ms.
This call gets past entries of 104ms or more and new entries of 16ms or more, because the buffer always uses the 104ms default.
observer.observe({ type: "event", durationThreshold: 16, buffered: true });
| Specification |
|---|
| Event Timing API # sec-performance-event-timing |