Client Hints (ch)¶
Client Hints allow the image optimisation API to automatically respond to browser-provided information about the viewport, device pixel ratio, and network conditions to deliver optimally sized and formatted images.
Parameters¶
Parameter | Type | Description |
---|---|---|
width |
boolean | Enable viewport width client hint support |
dpr |
boolean | Enable device pixel ratio client hint support |
savedata |
boolean | Enable save-data client hint support for data-conscious users |
Usage¶
Enable client hints by setting the desired parameters to true
:
Or enable individual hints:
Examples¶
Enable all client hints¶
Enable viewport width and DPR hints only¶
Enable save-data hint for bandwidth optimization¶
Client Hint Types¶
Width (width
)¶
When enabled, the API will use the browser's viewport width client hint to determine the optimal image width.
Device Pixel Ratio (dpr
)¶
When enabled, the API will use the device pixel ratio client hint to serve appropriately scaled images for high-DPI displays.
Save Data (savedata
)¶
When enabled, the API will detect the save-data client hint and deliver more compressed images to users who have enabled data saving mode in their browser.
Browser Support¶
Client Hints are supported by modern browsers. The API gracefully degrades when client hints are not available.
See Also¶
- Auto Parameter - Automatic optimization features
- Format Parameter - Image format selection
- Resize Parameter - Image sizing options