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
- Images never load: a script-based lazy loader conflicts with another. Use only one method.
- Embeds blank: see our YouTube guide.
Related guides
- WordPress High CPU Usage From wp-cron.php: How to Reduce It
- WordPress Site Is Slow: Practical Steps to Speed It Up
- WordPress Site Slow After an Update: Find the Cause
- WordPress Images Look Stretched or Wrong Size: Regenerate Thumbnails
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.