HTML Lazy Loading.
Lazy loading is a performance technique that delays the loading of images and iframes until the user scrolls near them, saving bandwidth and speeding up page load.
The Essentials
The 'loading' attribute is used on <img> and <iframe> tags.
loading='lazy' is the magic value that enables this feature.
loading='eager' (default) loads the element immediately.
It reduces the initial 'page weight' and improves Core Web Vitals.
Browsers handle the calculation of when to start loading automatically.
No JavaScript libraries are needed for this native feature.
Professional Insights
Performance Impact
Cumulative Layout Shift (CLS)
Above the Fold Rule
Browser Support
Critical Pitfalls
Lazy loading the main logo or hero image at the top of the page.
Forgetting width and height attributes, leading to layout shifts.
Using old jQuery plugins for lazy loading when the native attribute is faster.
Thinking lazy loading is for all elements—it's only for <img> and <iframe>.