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 integrates with several other features to bring progressive enhancements. Compatibility information for other lazy loaders can be found below.
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 image if necessary. Additionally, it works with responsive image support to make sure the image selected from a srcset listing is the best possible fit for the device.
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 EWWW IO 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' );
define( 'EIO_LL_AUTOSCALE', false );
Lazy Loading is not supported on IE8 or below, but all modern browsers are supported.
WebP, the leading nextgen image format, is supported in the latest releases of all major browsers except Safari. JS WebP Rewriting allows the plugin to detect WebP support, and deliver the correct image format to every visitor.
Printing pages with lazy loaded images does not work by default, as scrolling is needed to load all the images. EWWW I.O. 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.
EWWW IO is compatible with several lazy load plugins and themes, and while we recommend using our lazy loader, you can use whichever one works best for you.
ExactDN and JS (Alternative) 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
- Slider Revolution
- WP Retina 2x
- WP Rocket