PerformanceObserver.disconnect()

The disconnect() method of the PerformanceObserver interface is used to stop the performance observer from receiving any performance entry events.

Syntax

performanceObserver.disconnect();

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
  // ...
  // Disable additional performance events
  observer.disconnect();
}
var observer2 = new PerformanceObserver(perf_observer);
observer2.observe({entryTypes: ["measure"]});

Specifications

Specification
Performance Timeline
# dom-performanceobserver-disconnect

Browser compatibility

BCD tables only load in the browser