CPU compute pressure
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 | | | | |
| HTML attribute | ||||||
allow (compute-pressure) Experimental | 125 | 125 | | | | |
| DOM API | ||||||
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 | ||||||
compute-pressure Experimental The HTTP Permissions-Policy header compute-pressure directive controls access to the Compute Pressure API. | 125 | 125 | | | | |
Use cases
-
Using CPU compute pressure
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.
Cautions
- Limited browser support. Check compatibility before use.
Implementation notes
- Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.