The introduction of lazy-loading of images as of WordPress 5.5 improves site performance by delaying them until the user scrolls into view making our pages feel faster by only loading images as we need to see them.
However, I needed a way to disable lazy loading for specific features like this image carousel where the last few slides would not load as they rotated into view. 🙁
Disable lazy loading of the carousel images using this template part.
the_post_thumbnail( 'carousel', [ 'class' => 'orbit-image' , 'loading' => false ] );
The code above is inspired by modifying the attr argument using an array.
Adding ‘loading’ => false to the array disables the feature for this homepage image carousel.
Before and After
Disabling lazy loading for a specific use of the_post_thumbnail() allows us to benefit from the feature everywhere else. 😀