This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
* Some parts of this feature may have varying levels of support.
Note: This feature is available in Web Workers.
The PerformanceObserver interface is used to observe performance measurement events and be notified of new performance entries as they are recorded in the browser's performance timeline.
PerformanceObserver()Creates and returns a new PerformanceObserver object.
PerformanceObserver.supportedEntryTypes Read only
Returns an array of the entryType values supported by the user agent.
PerformanceObserver.observe()Specifies the set of entry types to observe. The performance observer's callback function will be invoked when performance entry is recorded for one of the specified entryTypes.
PerformanceObserver.disconnect()Stops the performance observer callback from receiving performance entries.
PerformanceObserver.takeRecords()Returns the current list of performance entries stored in the performance observer, emptying it out.
The following example creates a PerformanceObserver watching for "mark" (PerformanceMark) and "measure" (PerformanceMeasure) events. The perfObserver callback provides a list (PerformanceObserverEntryList) which allows you to get observed performance entries.
function perfObserver(list, observer) {
list.getEntries().forEach((entry) => {
if (entry.entryType === "mark") {
console.log(`${entry.name}'s startTime: ${entry.startTime}`);
}
if (entry.entryType === "measure") {
console.log(`${entry.name}'s duration: ${entry.duration}`);
}
});
}
const observer = new PerformanceObserver(perfObserver);
observer.observe({ entryTypes: ["measure", "mark"] });
| Specification |
|---|
| Performance Timeline> # dom-performanceobserver> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
PerformanceObserver |
52 | 79 | 57 | 39 | 11 | 52 | 57 | 41 | 11 | 6.0 | 52 | 11 |
PerformanceObserver |
52 | 79 | 57 | 39 | 11 | 52 | 57 | 41 | 11 | 6.0 | 52 | 11 |
disconnect |
52 | 79 | 57 | 39 | 11 | 52 | 57 | 41 | 11 | 6.0 | 52 | 11 |
observe |
52 | 79 | 57 | 39 | 11 | 52 | 57 | 41 | 11 | 6.0 | 52 | 11 |
supportedEntryTypes_static |
73 | 79 | 68 | 60 | 13 | 73 | 68 | 52 | 13 | 11.0 | 73 | 13 |
takeRecords |
65 | 79 | 60 | 52 | 15 | 65 | 60 | 47 | 15 | 9.0 | 65 | 15 |
worker_support |
62 | 79 | 57 | 49 | 11 | 62 | 57 | 46 | 11 | 8.0 | 62 | 11 |
© 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/PerformanceObserver