Skip to content

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:

?ch=width,dpr,savedata

Or enable individual hints:

?width=true&dpr=true&savedata=true

Examples

Enable all client hints

https://your-domain.com/image.jpg?ch=width,dpr,savedata

Enable viewport width and DPR hints only

https://your-domain.com/image.jpg?ch=width,dpr

Enable save-data hint for bandwidth optimization

https://your-domain.com/image.jpg?ch=savedata

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