PerformanceObserver()

The PerformanceObserver() constructor creates a new PerformanceObserver object with the given observer callback. The observer callback is invoked when performance entry events are recorded for the entry types that have been registered, via the observe() method.

Syntax

var observer = new PerformanceObserver(callback);

Parameters

callback
A PerformanceObserverCallback callback that will be invoked when observed performance events are recorded. When the callback is invoked, its first parameter is a list of performance observer entries and the second parameter is the observer object.

Return value

A new PerformanceObserver object which will call the specified callback when observed performance events occur.

Example

var observer = new PerformanceObserver(function(list, obj) {
  var entries = list.getEntries();
  for (var i=0; i < entries.length; i++) {
    // Process "mark" and "frame" events
  }
});
observer.observe({entryTypes: ["mark", "frame"]});

function perf_observer(list, observer) {
  // Process the "measure" event 
}
var observer2 = new PerformanceObserver(perf_observer);
observer2.observe({entryTypes: ["measure"]});

Specifications

Specification Status Comment
Performance Timeline Level 2
The definition of 'PerformanceObserver()' in that specification.
Candidate Recommendation Initial definition of PerformanceObserver() constructor.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 52Edge ? Firefox Full support 57IE No support NoOpera Full support 39Safari Full support 11WebView Android No support NoChrome Android Full support 52Edge Mobile ? Firefox Android Full support 57Opera Android Full support 39Safari iOS Full support 11Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

Document Tags and Contributors

Contributors to this page: Sheppy, fscholz, jpmedley, chrisdavidmills, teoli, rolfedh, AFBarstow
Last updated by: Sheppy,