Without explicit height and width attributes on the img elements, the browser will need to adjust the layout after every image is downloaded to make room for the content. Setting explicit image dimensions allows the browser to avoid additional layout adjustments, reduces movement of page content, and shortens the duration of the full page render.
The browser should be able to use the height and width to adjust the layout of the page before images are downloaded and the Lighthouse audit should no longer report this issue for any image.
Describe the bug
From the Chrome Lighthouse performance audit:
Without explicit height and width attributes on the
img
elements, the browser will need to adjust the layout after every image is downloaded to make room for the content. Setting explicit image dimensions allows the browser to avoid additional layout adjustments, reduces movement of page content, and shortens the duration of the full page render.To Reproduce
Expected behavior
The browser should be able to use the height and width to adjust the layout of the page before images are downloaded and the Lighthouse audit should no longer report this issue for any image.
See Images Without Dimensions for more information about this issue and how to fix it.
⚠️ Make sure that mobile/responsive image sizes are either not affected or adjusted along with this change.