PerformanceObserver.disconnect()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.
PerformanceObserver
接口的 disconnect()
方法用于阻止性能观察者接收任何 性能条目 事件。
语法
js
disconnect()
参数
无。
返回值
无(undefined
)。
示例
js
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 |
---|
Performance Timeline # dom-performanceobserver-disconnect |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
disconnect |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.