W3cubDocs

/Web APIs

PerformanceEventTiming: cancelable property

The read-only cancelable property returns the associated event's cancelable property, indicating whether the event can be canceled.

Value

A boolean. true if the associated event is cancelable, false otherwise.

Examples

Observing non-cancelable events

The cancelable property can be used when observing event-timing entries (PerformanceEventTiming). For example, to log and measure non-cancelable events only.

js

const observer = new PerformanceObserver((list) => {
  list.getEntries().forEach((entry) => {
    if (!entry.cancelable) {
      const delay = entry.processingStart - entry.startTime;
      console.log(entry.name, delay);
    }
  });
});

// Register the observer for events
observer.observe({ type: "event", buffered: true });

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
cancelable 76 79 89 No 63 No 76 76 89 54 No 12.0

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEventTiming/cancelable