-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
43 lines (30 loc) · 1.14 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---
title: "PerformanceEventTiming: cancelable property"
short-title: cancelable
slug: Web/API/PerformanceEventTiming/cancelable
page-type: web-api-instance-property
browser-compat: api.PerformanceEventTiming.cancelable
---
{{APIRef("Performance API")}}
The read-only **`cancelable`** property returns the associated event's [`cancelable`](/en-US/docs/Web/API/Event/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 ({{domxref("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
{{Specifications}}
## Browser compatibility
{{Compat}}