PerformanceObserver()

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

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 observered 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.

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 Time Level 2
The definition of 'PerformanceObserver()' in that specification.
Editor's Draft Initial definition of PerformanceObserver() constructor.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 52.0 49 (49)[1] No support 39 No support
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile Chrome for Android
Basic support No support No support 49 (49)[1] No support No support

39

No support 52.0

[1] Only activated in Nightly builds. Controlled by the dom.enable_performance_observer preference. 

Document Tags and Contributors

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