Advertisement
Home Open Editor ❯

HTML <img> loading Attribute

Example

<img loading="lazy" src="img-boy.jpg" alt="Boy" width="300" height="200">

Try this code ❯

Meaning

The loading attribute specifies how the browser should load the image.


Standard Syntax

HTML: <img src="URL" alt="text" loading="eager|lazy">,
XHTML: <img src="URL" alt="text" loading="eager|lazy" />


Advertisement

Attribute Values

Value Description
eager Loads the image immediately, regardless of whether or not the image is currently within the visible viewport (default).
lazy Defers loading the image until it reaches a calculated distance from the viewport, as defined by the browser. The intent is to avoid the network and storage bandwidth needed to handle the image until it's reasonably certain that it will be needed. This generally improves the performance of the content in most typical use cases.
Home Open Editor ❯
Advertisement