Performance: clearResourceTimings() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2017.

Note: This feature is available in Web Workers.

The clearResourceTimings() method removes all performance entries with an entryType of "resource" from the browser's performance timeline and sets the size of the performance resource data buffer to zero.

To set the size of the browser's performance resource data buffer, use the Performance.setResourceTimingBufferSize() method.

To get notified when the browser's resource timing buffer is full, listen for the resourcetimingbufferfull event.

Syntax

js
clearResourceTimings()

Parameters

None.

Return value

None (undefined).

Examples

Clearing the performance resource data buffer

To remove all resource performance entries from the buffer, call the clearResourceTimings() at an appropriate point in your code or paste it into the console.

js
performance.clearResourceTimings();
performance.getEntriesByType("resource").length; // 0

Taking records and emptying performance observers

When using PerformanceObserver objects (especially with the buffered flag set to true), the performance resource buffer might get full quickly. However, instead of clearing the buffer, you can also store the current list of performance entries and empty the performance observer using the PerformanceObserver.takeRecords() method. This works with all kinds of performance entry types, not just "resource" entries.

js
function perfObserver(list, observer) {
  list.getEntries().forEach((entry) => {
    // do something with the entries
  });
}
const observer = new PerformanceObserver(perfObserver);
observer.observe({ type: "resource", buffered: true });

// Store entries and empty performance observer
const records = observer.takeRecords();

Specifications

Specification
Resource Timing
# dom-performance-clearresourcetimings

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
Node.js
clearResourceTimings
Chrome – No support
Chrome 22 – 56 (Release date: 2012-09-25)
prefix
footnote Removed in 57 and later
prefix Implemented with the vendor prefix: webkit
Chrome – Full support
Chrome 46 (Release date: 2015-10-13)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 35 (Release date: 2015-01-13)
footnote Full support
Opera – No support
Opera 15 – 43 (Release date: 2013-07-02)
prefix
footnote Removed in 44 and later
prefix Implemented with the vendor prefix: webkit
Opera – Full support
Opera 33 (Release date: 2015-10-27)
footnote Full support
Safari – Full support
Safari 11 (Release date: 2017-09-19)
footnote Full support
Chrome Android – No support
Chrome Android 25 – 56 (Release date: 2013-02-27)
prefix
footnote Removed in 57 and later
prefix Implemented with the vendor prefix: webkit
Chrome Android – Full support
Chrome Android 46 (Release date: 2015-10-14)
footnote Full support
Firefox for Android – Full support
Firefox for Android 35 (Release date: 2015-01-13)
footnote Full support
Opera Android – No support
Opera Android 14 – 42 (Release date: 2013-05-21)
prefix
footnote Removed in 43 and later
prefix Implemented with the vendor prefix: webkit
Opera Android – Full support
Opera Android 33 (Release date: 2015-11-03)
footnote Full support
Safari on iOS – Full support
Safari on iOS 11 (Release date: 2017-09-19)
footnote Full support
Samsung Internet – No support
Samsung Internet 1.5 – 6.4 (Release date: 2013-09-25)
prefix
footnote Removed in 7 and later
prefix Implemented with the vendor prefix: webkit
Samsung Internet – Full support
Samsung Internet 5 (Release date: 2016-12-15)
footnote Full support
WebView Android – No support
WebView Android 4.4 – 56 (Release date: 2013-12-09)
prefix
footnote Removed in 57 and later
prefix Implemented with the vendor prefix: webkit
WebView Android – Full support
WebView Android 46 (Release date: 2015-10-14)
footnote Full support
WebView on iOS – Full support
WebView on iOS 11 (Release date: 2017-09-19)
footnote Full support
Bun – Full support
Bun 1.1.37 (Release date: 2024-11-26)
footnote Full support
Deno – Full support
Deno 2.7 (Release date: 2026-02-25)
footnote Full support
Node.js – No support
Node.js 16.17 – 16.17 (Release date: 2022-08-16)
footnote Removed in 17 and later
Node.js – Full support
Node.js 18.2 (Release date: 2022-05-17)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Requires a vendor prefix or different name for use.
Has more compatibility info.

See also