PeformanceObserver.disconnect()

 

PerformanceObserver 接口的 disconnect() 方法用于阻止性能观察者接收任何 性能条目 事件。

语法

performanceObserver.disconnect();

例子

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"]});

规范

Specification Status Comment
Performance Timeline Level 2
disconnect()
Candidate Recommendation disconnect() 方法的初始定义。

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
disconnectChrome Full support 52Edge ? Firefox Full support 57IE No support NoOpera Full support 39Safari Full support 11WebView Android Full support 52Chrome Android Full support 52Firefox Android Full support 57Opera Android Full support 41Safari iOS Full support 11Samsung Internet Android ?

Legend

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