CPU compute pressure
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Note: This feature is available in Web Workers, except for Service Workers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The PressureObserver interface is part of the Compute Pressure API and is used to observe the pressure changes of system resources such as the CPU.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
PressureObserver Experimental | 125 | 125 | | | | |
disconnect Experimental The disconnect() method of the PressureObserver interface stops the pressure observer callback from receiving pressure records from all sources. | 125 | 125 | | | | |
knownSources_static Experimental The static knownSources read-only property of the PressureObserver interface returns an array of the PressureRecord.source values supported by the user agent in alphabetical order. | 125 | 125 | | | | |
observe Experimental The observe() method of the PressureObserver interface tells the pressure observer to start observing pressure changes. After this method is called, the observer will call its callback function when a pressure record for the specified source is observed. | 125 | 125 | | | | |
PressureObserver Experimental The PressureObserver() constructor creates a new PressureObserver object to watch for changes to pressure changes of system resources such as the CPU. | 125 | 125 | | | | |
takeRecords Experimental The takeRecords() method of the PressureObserver interface returns the current list of pressure records stored in the pressure observer, emptying it out. | 125 | 125 | | | | |
unobserve Experimental The unobserve() method of the PressureObserver interface stops the pressure observer callback from receiving pressure records from the specified source. | 125 | 125 | | | | |
PressureRecord Experimental The PressureRecord interface is part of the Compute Pressure API and describes the pressure trend of a source at a specific moment of transition. | 125 | 125 | | | | |
source Experimental The read-only source property is a string indicating the origin source from which the record is coming. | 125 | 125 | | | | |
state Experimental The read-only state property is a string indicating the pressure state recorded. | 125 | 125 | | | | |
time Experimental The read-only time property returns the DOMHighResTimeStamp recorded for a PressureRecord. It corresponds to the time the data was obtained from the system relative to the time origin of the global object in which the PressureObserver generated the notification. | 125 | 125 | | | | |
toJSON Experimental The toJSON() method is a Serialization; it returns a JSON representation of the PressureRecord object. | 125 | 125 | | | | |
| Other | ||||||
html.elements.iframe.allow.compute-pressure Experimental | 125 | 125 | | | | |
http.headers.Permissions-Policy.compute-pressure Experimental The HTTP Permissions-Policy header compute-pressure directive controls access to the Compute Pressure API. | 125 | 125 | | | | |
Syntax
const observer = new PressureObserver((records) => {
for (const record of records) {
console.log('CPU state:', record.state); // 'nominal'|'fair'|'serious'|'critical'
}
});
observer.observe('cpu', { sampleInterval: 1000 }); Use cases
-
Use CPU compute pressure
Use CPU compute pressure when standard HTML needs a more specific platform feature, semantic signal, or browser capability.
-
Handle edge cases
Apply CPU compute pressure to solve a focused requirement without redesigning the whole page architecture.
Cautions
- Test CPU compute pressure in your target browsers and input environments before depending on it as a primary behavior.
- Provide a fallback path or acceptable degradation strategy when support is still limited.
Accessibility
- Make sure CPU compute pressure supports the intended task without making the page harder to perceive, understand, or operate.