Image-heavy pages are often slow for a simple reason: the browser downloads every picture on the page at once, including the ones near the bottom that most visitors never scroll down to see. Lazy loading images fixes this by delaying offscreen images until the reader gets close to them. Done well, the first screen of your page loads sooner and visitors use less data. Done carelessly, it can make your most important image slower and make your layout jump around.
This guide covers how lazy loading works, how to turn it on with plain HTML, which images you should leave alone, and how to avoid the common mistakes that cause problems with layout and search engines.
What Lazy Loading Actually Does
Normally, when a browser reads your page, it finds every image tag and starts requesting those files right away. On a short page with two or three photos, that is fine. On a long blog post, a photography portfolio or a product category page with dozens of images, it means the browser spends bandwidth and processing time on pictures the reader cannot see yet.
With lazy loading, the browser skips images that are far below the visible area. As the reader scrolls and an image gets close to the viewport, the browser fetches it. Browsers start loading a little before the image actually appears, so on a normal connection the reader rarely sees an empty space.
The benefits are practical:
- Faster first view. The images at the top of the page compete with fewer requests.
- Less wasted data. Visitors who leave halfway down the page never download the rest.
- Lighter load on your hosting. Fewer image requests are served for pages that are only partly read.
How to Turn On Native Lazy Loading
Modern browsers support lazy loading directly in HTML, so you no longer need a JavaScript library for most sites.
Add the loading attribute
Add loading=”lazy” to the image tag of any picture that sits below the first screen. The rest of the tag stays the same: the source URL, the alt text and the dimensions. Browsers that do not recognize the attribute simply ignore it and load the image normally, so adding it carries little risk.
If you use a content management system, check whether it already does this for you. WordPress, for example, adds lazy loading to content images automatically, and many themes and page builders have a setting for it. Look at your page source before adding a plugin, or you may end up with two systems doing the same job.
Always set width and height
This is the step people skip most often, and it matters more with lazy loading than without it. If an image tag has no width and height attributes, the browser does not know how much space to reserve. When the image finally arrives, the content below it gets pushed down. That jump is called layout shift, and it is frustrating for readers, especially if they were about to tap a link.
Set width and height to the image’s actual pixel dimensions, or at least to the correct proportions. Your CSS can still make the image responsive with a rule like a maximum width of 100 percent and an automatic height. The browser uses the two numbers to calculate the aspect ratio and holds the right amount of space before the file loads.
Lazy load embedded iframes too
The same loading=”lazy” attribute works on iframes, such as embedded videos and maps. These embeds are often heavier than images, so lazy loading them when they sit lower on the page can make a noticeable difference.
Which Images You Should Not Lazy Load
Lazy loading everything is the most common mistake. Images that appear in the first screen of the page should load right away.
Your hero image and above-the-fold photos
The large image at the top of a post, a homepage banner or the main photo on a product page is often the biggest element a visitor sees first. If you lazy load it, the browser waits until it has worked out the page layout before deciding the image is visible, which delays the very thing readers are waiting for. Leave the loading attribute off these images, or set it to eager, which is the default behavior.
A simple rule of thumb: do not lazy load anything that is likely to be visible without scrolling on a typical phone or laptop. When in doubt about the first one or two images on a page, load them normally.
Give the main image a priority hint
For the single most important image at the top of the page, you can add fetchpriority=”high”. This tells the browser to request that file ahead of less important resources. Use it sparingly. If you mark every image as high priority, the hint stops meaning anything.
Small logos and icons
A site logo in the header is visible immediately and is usually tiny. Lazy loading it saves almost nothing and can cause it to flicker in late.
Background Images and Older Setups
The loading attribute only applies to image tags and iframes. Images set as CSS backgrounds, such as a full-width section with a photo behind the text, are not covered.
If you have large background images further down a page, you have a few options:
- Switch to a regular image tag positioned behind the content with CSS. This lets you use native lazy loading and add alt text when the image carries meaning.
- Use the Intersection Observer API, a built-in browser feature that runs a small script when an element approaches the viewport. The script can add a CSS class that applies the background image only at that point.
- Keep the background image small by compressing it and serving a size that fits the section, so loading it early costs less.
Older JavaScript lazy loading libraries usually work by putting the real image URL in a data attribute and swapping it in later. If your site still uses one, consider replacing it with the native attribute. It is simpler, does not depend on a script loading correctly, and keeps the real image URL in the HTML where browsers and search engines expect it.
Lazy Loading and SEO
Native lazy loading is generally safe for search. Search engines that render pages can see images marked with loading=”lazy” because the real URL is right there in the tag.
Problems tend to come from custom implementations. Watch for these:
- Images that only load after a click, swipe or other interaction. Crawlers do not tap buttons, so those images may never be discovered.
- Missing image URLs in the HTML. If the source is a blank placeholder and the real address only appears through JavaScript, some crawlers may miss it.
- Lazy loading the main image. Slowing down the largest visible image can hurt page experience measurements.
Keep writing descriptive alt text for lazy-loaded images, just as you would for any other picture. Lazy loading changes when an image downloads, not how it should be described.
Lazy Loading with Hosted Images
Lazy loading works the same way whether your images live on your own server or with an image host. If you embed pictures from a service like ImageCoast, you can paste the direct image link into an image tag and add the loading attribute, width, height and alt text yourself. The host serves the file; your HTML controls when the browser asks for it.
A few tips help the two work well together:
- Upload images at sensible sizes. Lazy loading delays large files, but it does not make them smaller. A compressed image that matches the space it fills will always appear faster.
- Record each image’s dimensions when you upload it, so you have the width and height ready when you write the embed code.
- Test embeds in a private browser window and scroll slowly to confirm images appear before they enter view.
For long galleries and portfolios, hosting images on ImageCoast and lazy loading everything below the first row keeps the initial page light while still letting visitors browse the full collection.
A Quick Lazy Loading Checklist
- Leave the first visible images, especially the hero image, loading normally.
- Add fetchpriority=”high” to the single most important image at the top.
- Add loading=”lazy” to images and iframes further down the page.
- Set width and height on every image to prevent layout shift.
- Check whether your platform already lazy loads images before adding a plugin.
- Make sure no image depends on a click or swipe to load.
- Compress and resize images so they load quickly once requested.
- Scroll through the page on a phone to confirm nothing jumps or appears late.
Frequently Asked Questions
Does lazy loading work in all browsers?
Native lazy loading is supported in all major modern browsers. Browsers that do not support it ignore the attribute and load images normally, so your page still works.
Should I lazy load every image on my page?
No. Images visible without scrolling, particularly the main image at the top, should load right away. Lazy loading them can make the page feel slower.
Why does my page jump when lazy-loaded images appear?
The images are probably missing width and height attributes, so the browser cannot reserve space for them. Add the dimensions and keep your CSS set to scale the image proportionally.
Will lazy loading hurt my image search rankings?
Native lazy loading with the real image URL in the tag is generally safe for search engines. Problems usually come from scripts that hide the image address or require user interaction to load it.
Can I lazy load images embedded from an image host?
Yes. Lazy loading is controlled by the HTML on your page, not by where the file is stored, so hosted images can use the loading attribute like any other image.
Does lazy loading reduce my image file sizes?
No. It only changes when images are downloaded. To make each image load faster, compress it and serve dimensions that match how large it appears on the page.