Performance: setResourceTimingBufferSize() 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.
Phương thức setResourceTimingBufferSize() đặt kích thước mong muốn của bộ đệm resource timing của trình duyệt, nơi lưu trữ các performance entry kiểu "resource".
Đặc tả yêu cầu bộ đệm resource timing ban đầu phải là 250 hoặc lớn hơn.
Để xóa bộ đệm dữ liệu performance resource của trình duyệt, hãy dùng phương thức Performance.clearResourceTimings().
Để được thông báo khi bộ đệm resource timing của trình duyệt đầy, hãy lắng nghe sự kiện resourcetimingbufferfull.
Cú pháp
setResourceTimingBufferSize(maxSize)
Tham số
maxSize-
Một
numberbiểu thị số lượng tối đa đối tượngPerformanceEntrymà trình duyệt nên giữ trong bộ đệm performance entry của nó.
Giá trị trả về
Không có (undefined).
Ví dụ
>Đặt kích thước bộ đệm resource timing
Lệnh gọi sau cho phép 500 performance entry "resource" trong performance timeline của trình duyệt.
performance.setResourceTimingBufferSize(500);
Nếu bạn đặt kích thước bộ đệm nhỏ hơn số entry hiện có trong bộ đệm, sẽ không có entry nào bị xóa. Thay vào đó, để xóa bộ đệm, hãy gọi Performance.clearResourceTimings().
performance.getEntriesByType("resource").length; // 20
performance.setResourceTimingBufferSize(10);
performance.getEntriesByType("resource").length; // 20
performance.clearResourceTimings();
performance.getEntriesByType("resource").length; // 0
Thông số kỹ thuật
| Specification |
|---|
| Resource Timing> # dom-performance-setresourcetimingbuffersize> |