PerformanceObserver
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.
Note: This feature is available in Web Workers
Constructor
PerformanceObserver()-
Creates and returns a new
PerformanceObserverobject.
Properties
PerformanceObserver.supportedEntryTypesRead only-
Returns an array of the
entryTypevalues supported by the user agent.
Methods
PerformanceObserver.observe()-
Specifies the set of
entry typesto observe. The performance observer's callback function will be invoked when aperformance entryis recorded for one of the specifiedentryTypes PerformanceObserver.disconnect()-
Stops the performance observer callback from receiving
performance entries. PerformanceObserver.takeRecords()-
Returns the current list of
performance entriesstored in the performance observer, emptying it out.
Example
function observer_callback(list, observer) {
// Process the "measure" event
}
let observer = new PerformanceObserver(observer_callback);
observer.observe({entryTypes: ["measure"]});
Specifications
| Specification |
|---|
| Performance Timeline # dom-performanceobserver |
Browser compatibility
BCD tables only load in the browser