A page often loads dozens of images and several embeds the visitor has not scrolled to yet, and they all compete for bandwidth with what is actually on screen. Lazy loading makes them wait until they are needed. The most important image, the big one at the top, should do the opposite: load first. Keel does both.
Turn on lazy loading
- Open Keel › Speed › Lazy loading.
- Switch on Lazy load images. Every image waits until it is about to scroll into view, including images in text fields and hard-coded images in your theme.
- Switch on Lazy load videos and embeds. YouTube, Vimeo, maps and other embeds wait too. These are often the heaviest things on a page, so this switch usually saves more than the first.
Leave the top images alone
The logo and the hero image are visible immediately, so they must not wait. Images at the top that load immediately sets how many images at the start of the page skip lazy loading. Two suits most layouts: the logo and the hero. Raise it if your header has several images, such as a logo, a badge and a hero.
To exclude a specific image anywhere on the page (an image in a slider or tab that a script measures, for example), give it a CSS class and add that class to Never lazy load images with these classes.
Load the main image first
Load the main image first finds the first large image at the top of the page and gives it top download priority, so the browser starts fetching it before less important files, even before it has finished reading the styles.
That image is usually what Google measures for Largest Contentful Paint, one of the three Core Web Vitals. Logos and images with the class no-hero are skipped, so the priority goes to the right image.
Video previews (Keel Pro)
Even lazy loaded, a video player loads hundreds of kilobytes of scripts as the visitor scrolls past. Video previews instead of players shows a YouTube or Vimeo video as its thumbnail with a play button; the real player loads only when someone clicks. That saves around 700 KB per video. Add data-no-facade to an iframe to keep a normal player there.
Check the result
- Run the page through PageSpeed Insights on mobile, before and after.
- Look at Largest Contentful Paint. It should drop.
- Expand the LCP element in the diagnostics. It must not say the image was lazily loaded.
- Scroll down the page on a phone. Images should appear as you reach them, without blank gaps.
Troubleshooting
| Problem | Fix |
|---|---|
| An image at the top pops in late | Raise Images at the top that load immediately. |
| A slider or gallery shows blank slides | Add the slider images’ class to Never lazy load images with these classes. |
| The wrong image gets priority | Give the image that should not be the hero the class no-hero. |
| Text jumps as images load | The images lack width and height. Images from the media library have them; check images added with custom HTML. |
Every setting on this screen
The same explanations you see next to each setting in Keel.
Keel › Speed › Lazy loading
| Setting | What it does |
|---|---|
| Lazy load images | Every image on the page waits until it is about to scroll into view, including images in text fields and hard-coded ones. |
| Lazy load videos and embeds | YouTube, Vimeo, maps and other embeds wait until they are needed. These are often the heaviest things on a page. |
| Images at the top that load immediately | The logo and the hero image are visible straight away, so they should not wait. 2 suits most layouts. |
| Never lazy load images with these classes | Add one of these CSS classes to an image to always load it immediately. Separate several with spaces. |
| Load the main image first | The first large image at the top of the page (the hero) is what Google times as "Largest Contentful Paint". It gets top download priority and starts loading before the styles. Logos and images with the class "no-hero" are skipped. |
| Video previews instead of players (Pro) | YouTube and Vimeo videos show their picture with a play button; the real player loads when clicked. Saves about 700 KB per video. Add data-no-facade to an iframe to skip it. |