Guides › HTML / PHP sites › Speed & performance

Lazy Loading Images and Iframes Correctly (and When Not to Use It)

Add loading=lazy to below-the-fold media, and keep your main image eager.

Reference guide. This guide is written from established practice and the official documentation of the tools involved. We have not yet tested every step on a live demo site. Back up your site before you change anything.

Lazy loading delays offscreen images until the visitor scrolls near them.

Use it

<img src="photo.jpg" loading="lazy" width="800" height="533" alt="...">
<iframe src="https://www.youtube.com/embed/ID" loading="lazy"></iframe>

Do not use it for

The main image at the top of the page (the LCP image). Lazy loading it makes the page feel slower. See our vitals guide.

Always set dimensions

Without width and height, the page jumps as images load.

Problems

Related guides

Did this solve it? If not, email hello@sitefixlab.org with the exact error text and we will look into it. Try the problem finder.

Last updated 2026-11-21.