sandywp / plugins / rocket-lazy-load

LazyLoad Plugin

Lazy Load Images, Videos, and Iframes

4.2 out of 5 stars. 4.2 139 reviews

The best free lazy load plugin for WordPress. Lazy load images, videos, and iframes to improve performance and Core Web Vitals scores.

Launch a sandbox with this plugin → No signup.
Ready in seconds.

v2.4.1 100,000+ installs WP 4.9+ PHP 7.4+

your-sandbox.sandywp.com/wp-admin
LazyLoad Plugin – Lazy Load Images, Videos, and Iframes running inside a SandyWP sandbox

About this plugin

LazyLoad is the best free lazy load plugin for WordPress to lazy load images, videos, and iframes on WordPress. In a nutshell, LazyLoad displays images, videos, and iframes on a page only when they are visible to the user – that’s one crucial way to speed up your WordPress site and optimize images for Google PageSpeed.

You can lazy load images in post content or widget text, plus thumbnails, avatars, and smilies. LazyLoad takes care of iframe lazy load, too: you’ll easily replace Youtube iframes with a preview thumbnail to further speed up the loading time of your website.

No JavaScript library such as jQuery is used, and the script weight is less than 10KB.

Why is lazy loading crucial for performance?

Lazy loading is a key performance technique to make your site faster. You’ll reduce loading time, improve your Lighthouse performance score and optimize your Core Web Vitals grades.

Lazy loading your images on WordPress will help you achieve a better PageSpeed Insights score for three main reasons:

Take a look at our complete list of reasons why you should use lazy loading. Then, turn on LazyLoad and make your WordPress website faster!

Dependencies

LazyLoad script: https://github.com/verlok/lazyload

Questions

How can I use native lazyload?

To use native lazyload on browsers supporting this feature, you need to use the following line:

add_filter( 'rocket_use_native_lazyload', '__return_true' );

Browsers that do not support native lazyload will use the JS-based solution as before.

How can I deactivate Lazy Load on some pages?

You can use the do_rocket_lazyload filter.

Here is an example to put in functions.php files that disable lazyload on posts:

add_action( 'wp', 'deactivate_rocket_lazyload_on_single' );
function deactivate_rocket_lazyload_on_single() {
    if ( is_single() ) {
        add_filter( 'do_rocket_lazyload', '__return_false' );
    }
}

How can I deactivate Lazy Load on some images?

Simply add a data-no-lazy="1" property in you img or iframe tag.

You can also use the filters rocket_lazyload_excluded_attributes or rocket_lazyload_excluded_src to exclude specific patterns.

For iframes, the filter is rocket_lazyload_iframe_excluded_patterns.

How can I change the threshold to trigger the load?

You can use the rocket_lazyload_threshold filter.

Code sample:

function rocket_lazyload_custom_threshold( $threshold ) {
    return 100;
}
add_filter( 'rocket_lazyload_threshold', 'rocket_lazyload_custom_threshold' );

How to remove the “ tag

You can use the rocket_lazyload_noscript filter to disable the addition of the <noscript> tag used for compatibility when JS is disabled.

add_filter( 'rocket_lazyload_noscript', '__return_false' );

How to change the image placeholder for lazyloaded images

You can use the rocket_lazyload_placeholder to change the default placeholder for lazyloaded images.

function rocket_lazyload_custom_placeholder( $placeholder ) {
    return 'default.jpg';
}
add_filter( 'rocket_lazyload_placeholder', 'rocket_lazyload_custom_placeholder' );

How to change the HTML output before sending to the browser

You can use the rocket_lazyload_html filter to modify the HTML output generated after applying the lazyload and before sending it to the browser.

How to exclude YouTube videos from lazyload

You can use the rocket_lazyload_exclude_youtube_thumbnail filter to exclude patterns matching with the YouTube videos you don’t want to lazyload.

function rocket_lazyload_exclude_youtube( $patterns ) {
    $patterns[] = 'string_to_match';

    return $patterns;
}
add_filter( 'rocket_lazyload_exclude_youtube_thumbnail', 'rocket_lazyload_exclude_youtube' );

4.2

139 reviews

  • 5 ★ 98
  • 4 ★ 9
  • 3 ★ 7
  • 2 ★ 6
  • 1 ★ 19

Ratings come from WordPress.org. SandyWP does not collect its own reviews.

sandywp / also on the shelf

Try another plugin

Spin up a real WordPress site in seconds.

Test plugins, build a demo, hand a client a link — then squash it and start again. No local setup, no Docker.