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() 方法。

注意: 此特征可用于 Web 工作者 .

句法

performance.clearResourceTimings();
					

自变量

void

返回值

none

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.
候选推荐 初始定义。

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
clearResourceTimings Chrome 46
46
22 — 57 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox Yes IE Yes Opera Yes Safari 11 WebView Android 46
46
? — 57 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android 46
46
25 — 57 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android Yes Opera Android Yes Safari iOS 11 Samsung Internet Android 5.0
5.0
1.5 — 7.0 Prefixed
Prefixed Implemented with the vendor prefix: webkit

图例

完整支持

完整支持

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

元数据

  • 最后修改:
  1. 资源计时 API
  2. 性能
  3. 特性
    1. navigation
    2. onresourcetimingbufferfull
    3. timeOrigin
    4. timing
  4. 方法
    1. clearMarks()
    2. clearMeasures()
    3. clearResourceTimings()
    4. getEntries()
    5. getEntriesByName()
    6. getEntriesByType()
    7. mark()
    8. measure()
    9. now()
    10. setResourceTimingBufferSize()
    11. toJSON()
  5. 事件
    1. resourcetimingbufferfull
  6. Related pages for Resource Timing API
    1. PerformanceEntry
    2. PerformanceResourceTiming
    3. Window.performance

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1