Rule n° 119 - Thumbnails and previews are not larger images resized on the client side.
The HTML language makes it possible to indicate dimensions for an image that are different from those of the original image. This makes it possible to create thumbnails and image previews. For example, you can perfectly display a square image with 100 pixels on each side, whereas it is a square image with 5000 pixels on each side for which you have simply resized the display in HTML. The display is small but the amount of data to download remains the same. This directly affects the performance of the site and thus should be avoided.
Goal
- Decrease the amount of data to download.
- Improve page display speed.
- Decrease the energy impact related to the consultation of the site.
Solution technique
For image preview vignettes, use specific versions of them and not original images resized using their HTML attributes or CSS properties.
Moyen de contrôle
For all HTML images present in the source code or generated via javascript:
- Check that they do not have CSS
heightorwidthproperties which modify the apparent size of the images in relation to their actual dimensions.To do this, use "deactivate all CSS styles" using a web development tool to find images whose dimensions change after deactivating CSS styles. - Also check that the dimensions indicated in the
widthandheightattributes of the generated HTML code correspond to the actual dimensions of the image using a development tool.
For example, the following will be invalidated:
- An image of the type <img height="300" width="600" class="thumb"/> if the
.thumbclass imposes the CSS propertiesheight: 100pxandwidth: auto. - An image of the type <img height="100" width="200"/> if the actual dimensions of the image are 300px high and 600px wide.