Image Elements Do Not Have Explicit Width and Height In Magento 2 Optimization

The < img > width attribute is used to set the width of the image in pixels.In this example, we will set the width and height of an image.
Applying a width and height attribute the browser can now calculate the aspect ratio before it renders the image element and can reserve enough space for the image once it downloads.

1. Identification

Tools like GTMetrix,lighthouse, Page speed insights.
Example:
Before
< img src=”https://magento-303896-1016412.cloudwaysapps.com/pub/media/wysiwyg/placeholder-565×300.jpg”
data-src=”https://magento-303896-1016412.cloudwaysapps.com/pub/media/wysiwyg/car-organisation-img.jpg”
class=”lazyload”
alt=”car-organisation”/ >
After
< img src=”https://magento-303896-1016412.cloudwaysapps.com/pub/media/wysiwyg/placeholder-565×300.jpg”
data-src=”https://magento-303896-1016412.cloudwaysapps.com/pub/media/wysiwyg/car-organisation-img.jpg”
class=”lazyload”
alt=”car-organisation”
width=”565″
height=”300″/>

Latest Posts

Leave A Comment