Lazy Load

Implementing Lazy Load for your images improves the load times of your page, as it prevents images from loading until they are in (or near) the viewport. On an image heavy site, this can make a huge difference, but the advantages don't stop there.

The Lazy Load implementation in EWWW IO (and Easy IO) integrates with several other features to bring progressive enhancements. Compatibility information for other lazy loaders can be found below.

WordPress (browser-native) Lazy Load

As of WP 5.5, native browser-based lazy load is enabled for all images, which is a great boost for image-heavy sites. But will it work with EWWW IO's lazy loading? Should you even use a JS-based (JavaScript) lazy loader when you have browser-native lazy loading?

Yes and yes... The lazy loader in EWWW IO was built to work alongside native lazy loading, but by default native lazy loading will be disabled to prevent problems with plugins/themes that don't support native lazy load.

So, can you still use them both together? EWWW IO uses blank placeholders the same size as your original images which allows the plugin to prevent layout "jank" and feeds the auto-scaling feature with correct sizing information that you just can't get with a 1x1 placeholder image. If you would like to lazy load those placeholders, define the EIO_ENABLE_NATIVE_LAZY constant as true in wp-config.php:

define( 'EIO_ENABLE_NATIVE_LAZY', true );

Please be sure to test your site after enabling native lazy load, especially looking for images that are not the right size.

JS WebP Rewriting

This integration allows us to bring nextgen image formats to supported browsers, without the sizing issues that arise from JS-driven theme layouts. Previously, JS WebP could be prone to layout issues in themes that expected all the images to exist within the page from the beginning. The use of lazy load placeholders allows the theme to do it's calculations without waiting for the WebP images to actually load.

Additionally, the use of Lazy Load alongside JS WebP allows us to tackle more complex designs that use inline CSS background images (background-image property). This is a big win for performance, especially if your site makes extensive use of inline background images, or if you use the Cover Image block in the new WordPress block editor.

Easy IO (ExactDN)

This integration allows the lazy loader to to automatically calculate the correct dimensions of an image before it actually loads, and dynamically alter the URL to generate a better-sized image if necessary. It also works with responsive image support to make sure the image selected from a srcset listing is the best possible fit for the device.

Additionally, CSS background images can be dynamically resized if they are added via inline style attributes.

Resize Detection

This feature allows you to detect improper image scaling. In other words, if the image is too big for the page or device, this will flag the image with a lovely black and blue border. Integrated with Lazy Load, it is now able to re-check an image after it loads and replaces the placeholder image for better accuracy.


The lazy loader will enable auto-scaling for any images with srcset/responsive markup. It does this by settings the sizes attribute on an image to the exact calculated width of the img element. In some cases, this calculation may not be correct, so you can disable auto-scaling in several different ways.

The first way is by using a WordPress filter. This code can be added to your theme's functions.php (if you use a child theme), or to a custom plugin:

add_filter( 'eio_lazy_responsive', '__return_false' );
The second method is an override that can be added to functions.php, or in your wp-config.php file:
define( 'EIO_LL_AUTOSCALE', false );
There is one last method that can be used on individual images, which is to add the class 'skip-autoscale' or the attribute 'data-skip-autoscale'.

Viewport Threshold

Also known as the "root margin", this controls how eager the lazy loader is in pre-loading images. By default, the lazy loader uses a larger threshold than Firefox, but about half that of Chrome. It can be configured via EIO_LL_THRESHOLD in your child theme's functions.php, or in your wp-config.php file:
define( 'EIO_LL_THRESHOLD', 2000 );

Exclude Images

To exclude images from lazy loading, you may use the "data-skip-lazy" attribute or add the "skip-lazy" class to an img element. Additional exclusions may be added in the settings, or defined via EWWW_IMAGE_OPTIMIZER_LL_EXCLUDE, similar to EXACTDN_EXCLUDE.

Additional Notes

Lazy Loading is not supported on IE8 or below, but all modern browsers are supported.

Printing pages with lazy loaded images does not work by default, as scrolling is needed to load all the images. EWWW IO now includes an optional toggle to include the lazysizes print plugin if your users frequently print your pages. It can be enabled by defining the EWWW_IMAGE_OPTIMIZER_LAZY_PRINT constant as true in your wp-config.php file.

By default, the lazysizes.min.js script will be loaded in the footer of your page, but if this causes any conflicts with other JS, you can try loading it in the header so that it runs sooner:

define( 'EIO_LL_FOOTER', false );

3rd-party Compatibility

Easy IO and JS WebP Rewriting are the only features that have ANY limitations regarding lazy loading support, and to prevent bloat, we have limited our scope to support plugins that use these patterns:

  • Replacing src with data-lazy-src and replacing srcset with data-lazy-srcset.
  • Replacing src with data-src and replacing srcset with data-srcset. For WebP support, this pattern also requires that you add the attribute data-lazy-type="image" or add the lazyload class (since the data-src attribute could be used for other purposes than lazy loading).

These plugins are known to use the supported lazy load patterns and will work properly with all EWWW IO features:

  • a3 Lazy Load
  • BJ Lazy Load
  • Jetpack
  • Slider Revolution
  • WP Retina 2x (Perfect Images)
  • WP Rocket