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 PerformanceObserver object.

Properties

PerformanceObserver.supportedEntryTypesRead only

Returns an array of the entryType values supported by the user agent.

Methods

PerformanceObserver.observe()

Specifies the set of entry types to observe. The performance observer's callback function will be invoked when a 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.

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

See also