Image is a common last-step of every critical request chain. Reducing its size results in faster LCP. To dynamically reduce image size, the following steps are required:
To optimize images, it is suggested to use an image optimization proxy service. For best results, select a service, which is capable of:
We suggest the following services (based on most common deployment setups):
Cloudflare Image Resizing ยท Cloudflare Image Optimization docs
Create a new component to handle rendering of images inside of the application. For example, src/component/BaseImage/index.js, with following contents:
export function BaseImage(props) {
return (
<img {...props} />
)
}
Replace all places in the application where <img> component was rendered with newly created image implementation.
By creating an abstraction over images, the control over image element attributes was obtained. We can programmatically modify them to ensure most optimal images are loaded.
srcset and sizes attributes?// TODO: describe when best sizes defining option will be decided
loading attribute?// TODO: describe when best visibility checking logic will be decided
fetchPriority attribute?// TODO: maybe only allow manual use?