Some images are not lazyloaded

If you've already activated the LazyLoad and LazyLoad for CSS background images features, you've verified the page is cached, but some images are still not lazyloaded and/or PageSpeed lists some images under the Defer offscreen images audit, then it's possible to be caused by one of the reasons presented in this article.

These images use the data-src attribute which is on the compatibility list below.

The images are excluded for compatibility

When the code of the image contains certain attributes which are known to be used for conflicting purposes, they are automatically excluded.

If you want to check this for your site:

  • Visit your page while bypassing WP Rocket, by adding ?nowprocket to the URL, e.g. http://example.com?nowprocket
  • Go to View > Page Source to see the HTML
  • Find the image that isn't lazyloaded. Check the img tag for any of the following attributes or values which will cause the image to be excluded from LazyLoad:

data-src
data-no-lazy
data-lazy-original
data-lazy-src
data-lazysrc
data-lazyload
data-bgposition
data-envira-src
fullurl
lazy-slider-img
data-srcset
class="ls-l
class="ls-bg
soliloquy-image
loading="eager"
swatch-img
data-height-percentage
data-large_image
avia-bg-style-fixed
data-skip-lazy
skip-lazy
class="skip-lazy"
image-compare__

Images encoded in Base64

Background images with Base64 encoding are not lazyloaded to ensure compatibility.

Background images and Bridge Theme

Lazyloading of background images for Bridge theme is disabled for compatibility.

Images are using the content property

Lazyload and Lazyload for CSS background images are not compatible with images added using the content property in CSS.

Conflict with ShortPixel Global WebP rewrite

When this feature in ShortPixel is activated, our LazyLoad doesn't work correctly.

The markup isn't supported

Images which markup doesn't have the double quotation marks around the value of the src attribute can't be lazyloaded:

  • Non-supported markup:
    <img src=https:/website.com/folder/image.png class="photos">
  • Supported markup:
    <img src="https:/website.com/folder/image.png" class="photos">

Conflict with another lazy load script

If your theme or another plugin is also applying lazy load, this could cause conflicts and our LazyLoad may not work as expected.

Images injected by JavaScript

WP Rocket can only apply LazyLoad to images which are present in the HTML when the page loads. If a plugin is injecting images into the page with JavaScript after the page has loaded, they will not be lazyloaded.

On the other hand, the LazyLoad for CSS background images feature will work on images associated with new HTML classes that were injected by JavaScript.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.