clearResourceTimings()
メソッドは、entryType
が "resource
" のすべてのパフォーマンスエントリ
をブラウザのパフォーマンスデータバッファから削除し、パフォーマンスデータバッファのサイズをゼロに設定します。ブラウザのパフォーマンスデータバッファのサイズを設定するには、Performance.setResourceTimingBufferSize()
メソッドを使用します。
註: この機能は Web Workers 内で利用可能です。
構文
performance.clearResourceTimings();
引数
- void
戻り値
- なし
- このメソッドには戻り値はありません。
例
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 clearResourceTimings() の定義 |
勧告候補 | 初期定義 |
ブラウザの互換性
BCD tables only load in the browser
このページの互換性テーブルは構造化データから生成されます。データに貢献したい場合は https://github.com/mdn/browser-compat-data をチェックして、プルリクエストを送ってください。