clearResourceTimings()
方法移除所有
performance entries
采用
entryType
of "
resource
" from the browser's performance data buffer and sets the size of the performance data buffer to zero. To set the size of the browser's performance data buffer, use the
Performance.setResourceTimingBufferSize()
方法。
performance.clearResourceTimings();
This method has no return value.
function load_resource() {
var image = new Image();
image.src = "https://developer.mozilla.org/static/img/opengraph-logo.png";
}
function clear_performance_timings() {
if (performance === undefined) {
log("Browser does not support Web Performance");
return;
}
// Create a resource timing performance entry by loading an image
load_resource();
var supported = typeof performance.clearResourceTimings == "function";
if (supported) {
console.log("Run: performance.clearResourceTimings()");
performance.clearResourceTimings();
} else {
console.log("performance.clearResourceTimings() NOT supported");
return;
}
// getEntries should now return zero
var p = performance.getEntriesByType("resource");
if (p.length == 0)
console.log("... Performance data buffer cleared");
else
console.log("... Performance data buffer NOT cleared!");
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
Resource Timing Level 1
The definition of 'clearResourceTimings()' in that specification. |
候选推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
clearResourceTimings
|
Chrome
46
|
Edge 12 | Firefox Yes | IE Yes | Opera Yes | Safari 11 |
WebView Android
46
|
Chrome Android
46
|
Firefox Android Yes | Opera Android Yes | Safari iOS 11 |
Samsung Internet Android
5.0
|
完整支持
要求使用供应商前缀或不同名称。