Preparing images involves several separate decisions: dimensions, format and quality, followed by which version the browser downloads and when it starts loading it.
It is easier to work through one photograph first. We can compare the result before applying the same settings to an entire gallery. A smaller file that loses an important product detail has not solved the problem.
What image dimensions does the page need?
Start with the space the image will occupy. A card thumbnail, a main photograph and a picture opened in a gallery serve different purposes. One export width will not sensibly cover all of them.
Suppose a card occupies a few hundred pixels, but opening the gallery should reveal wood texture or construction details. The card can use a smaller version, with the larger one downloaded for the gallery. Fetching the gallery version merely to shrink it immediately adds unnecessary transfer.
File pixels and layout pixels
A CSS width and a file's resolution are different measurements. A photograph 6000 pixels wide remains that file even when the browser displays it as a small thumbnail.
Screen density matters as well. In an illustrative card 360 CSS pixels wide, a 720-pixel image can provide two photograph pixels for each layout pixel. That calculation explains variant selection without requiring every image to be exported at double resolution. The detail the image needs to show matters too.
A few variants chosen for real uses are usually easier to maintain than dozens of almost identical files. Keep the original separately, outside the directory delivered to visitors. It may be needed after a layout change; enlarging a thumbnail will not recover missing detail.
JPEG, WebP, AVIF or PNG?
Choose a format for the actual material. A photograph, a symbol with a transparent background and a screenshot containing small text respond differently to compression. An export that works for a photograph may make an interface harder to read.
WebP and AVIF are worth comparing with the existing format, but they do not promise the same saving for every image. PNG can suit lossless output, while SVG primarily suits vector artwork. The MDN image format guide explains the differences.
The quality slider needs the same care. “80” in one tool may not produce the same result as “80” in another. It is a setting of a particular encoder, so compare the resulting files rather than the numbers alone.
For simple variants, the Kaadeusz image converter is one option. Still inspect the export at a size close to its intended appearance on the page.
How do srcset and sizes work?
srcset lists available versions and sizes describes their layout width. The browser selects a file using factors including screen size and pixel density; the responsive image guide explains the mechanism.
This example assumes a 3:2 photo that fills a narrow layout and is at most 720 px wide on larger screens. Create each referenced file first:
<img
src="/images/workshop-720.webp"
srcset="/images/workshop-480.webp 480w,
/images/workshop-720.webp 720w,
/images/workshop-1440.webp 1440w"
sizes="(max-width: 760px) calc(100vw - 40px), 720px"
width="1440"
height="960"
alt="Wooden workbench with furniture parts laid out"
loading="lazy"
/>The example is for an image further down the page. CSS must still fit it to the container while preserving its proportions. Change sizes if your layout differs; an inaccurate hint cannot describe the space the image actually occupies.
File size and cropping are separate decisions
A simple CSS addition to the preceding example is:
img {
display: block;
max-width: 100%;
height: auto;
}This preserves the aspect ratio and keeps the image within its container. It does not impose a fixed height or decide which part of a photograph should remain visible. When a card needs a particular shape, decide separately what can be cropped and where the important subject sits.
Imagine a wide workshop photograph with the product on the right. Cropping it into a portrait card on a phone may leave only a wall. Reducing the file size or increasing quality will not bring the product back into the frame. A different crop position can help; a larger composition change may need a separate image.
The picture element can select a source for particular conditions, such as a different crop on a narrow screen. This serves a different purpose from offering several resolutions of the same photograph through srcset. A separate crop makes sense when it helps show the right part of the photograph.
When should images load, and how can the layout stay stable?
width and height let the browser determine proportions before downloading the file. loading="lazy" postpones loading until the image approaches the viewport according to browser behaviour. The img documentation describes these controls.
Do not automatically defer the main photo visible when the page opens. That can delay the content the visitor is already waiting to see.
Avoid assigning a high priority to every illustration too. Priority is useful when it identifies a small number of genuinely critical resources.
Check the main photograph separately
If a photograph is the largest visible element when the page opens, it may be responsible for LCP. Discovering its address late or applying unnecessary lazy loading can delay the main content. The LCP optimisation guide describes this situation.
For that image, compare when downloading begins with when it appears. Even a small file can appear late if the browser only learns its address after a script runs. Another export with stronger compression will not repair the loading sequence.
What belongs in an image's alt text?
Alternative text should convey the information an image contributes. For a project photograph, that means describing what it shows rather than repeating a filename or listing marketing phrases.
A purely decorative image may need an empty alt. A complex diagram also needs an explanation in the surrounding content; a short description cannot always replace every detail in the illustration. The W3C alternative-text decision tree helps choose the appropriate treatment.
How can you tell whether the image changes helped?
After exporting, return to the browser tools. The Network panel shows which variant was downloaded on a phone and a larger display, its size and when the request began. A thumbnail's appearance cannot tell us whether the browser fetched a small file or shrank a large one.
Compare an initial load with a repeat visit under normal settings. Disabling cache while using DevTools helps inspect a load without the earlier copy, so a previously downloaded larger variant does not obscure the comparison.
Compare the meaningful detail
View the original and exported image at a similar displayed size, then inspect a detail that matters to the reader: material texture, label lettering or an object's edge. A smooth background can look acceptable even after small text has become unreadable.
Record the resolution, file size and export settings. Choosing a slightly larger file because it shows the product more clearly is a reasonable decision. The image still needs to communicate information; reducing transfer should support that purpose.
If the file is smaller but still appears late, examine the whole loading path next. The website performance guide explains how to distinguish that problem from server response time and script execution.
A prepared image should be reasonably light, readable and downloaded when needed. Start with one important photograph; its actual behaviour will show which change is useful for the rest.