We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

PerformanceObserver.observe()

The observe() method of the PerformanceObserver interface is used to specify the set of performance interface types to observe. The performance observer's callback function will be invoked when a performance entry is recorded for one of the specified types.

The types are specified in an array of strings and the valid values are defined in PerformanceEntry.entryType.

Syntax

observer.observe(options);

Parameters

options
A PerformanceObserverInit dictionary with one member:
  • "entryTypes", an array of strings and the valid values for the strings are defined in PerformanceEntry.entryType. If a value is not valid, the browser will ignore it. If the options argument is not given or the array is empty, TypeError is thrown.

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 'observe()' in that specification.
Candidate Recommendation Initial definition of observe() method.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 52 57 (57) No support 39 No support
Available on workers 62 (Yes) (Yes) 49 (Yes)
Feature Android Webview Chrome for Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support No support 52 57.0 (57) No support

39

No support
Available on workers No support 62 (Yes) (Yes)

49

(Yes)

Document Tags and Contributors

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