W3cubDocs

/Web APIs

Performance: setResourceTimingBufferSize() method

The setResourceTimingBufferSize() method sets the desired size of the browser's resource timing buffer which stores the "resource" performance entries.

The specification requires the resource timing buffer initially to be 250 or greater.

To clear the browser's performance resource data buffer, use the Performance.clearResourceTimings() method.

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

Syntax

js

setResourceTimingBufferSize(maxSize)

Parameters

maxSize

A number representing the maximum number of performance entry objects the browser should hold in its performance entry buffer.

Return value

None (undefined).

Examples

Setting a resource timing buffer size

The following call allows 500 "resource" performance entries in the browser's performance timeline.

js

performance.setResourceTimingBufferSize(500);

If you set the buffer size to a number lower than the amount of current entries in the buffer, no entries will be removed. Instead, to clear the buffer, call Performance.clearResourceTimings().

js

performance.getEntriesByType("resource").length; // 20
performance.setResourceTimingBufferSize(10);
performance.getEntriesByType("resource").length; // 20

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

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
setResourceTimingBufferSize 4622–57 12 35 10 3315–44 11 464.4–57 4625–57 35 3314–43 11 5.01.5–7.0

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Performance/setResourceTimingBufferSize