Disabling LazyLoad on Specific Posts

If you want to disable LazyLoad on a specific post or page, you can do so directly on the Edit screen using the Cache Options meta box. Un-check the LazyLoad option and publish or update the post.

Edit screen with WP Rocket options

Note: This option will only be enabled if LazyLoad has been globally activated in Settings β†’ WP Rocket β†’ Basic.
The option was added in WP Rocket 2.5. In case you run an older version, our recommendation is to update to the latest version.

Disable LazyLoad programatically

You can programatically disable LazyLoad on specific posts or pages utilizing a WordPress filter. Use the following helper plugin as a boilerplate, and edit the code to fit your specific use case:

πŸ“₯  Download (.zip):  WP Rocket | No LazyLoad
Developers: You can find the code for this plugin on GitHub.

Heads up! You must delete the functions you don’t need before running this plugin, otherwise LazyLoad will be deactivated on single post pages, product pages, and search result pages.

Below are a couple of examples on how to come up with your own function.

Disable LazyLoad on All Pages

function deactivate_on_page() {
	if ( is_page() ) {
		add_filter( 'do_rocket_lazyload', '__return_false' );
	}
}
add_filter( 'wp', __NAMESPACE__ . '\deactivate_on_page' );

Disable LazyLoad on Front Page

The front page of your site is the one set in Settings β†’ Reading β†’ Front page displays. It can be an actual page, or an archive page with your latest blog posts.

function deactivate_on_front_page() {
	if ( is_front_page() ) {
		add_filter( 'do_rocket_lazyload', '__return_false' );
	}
}
add_filter( 'wp', __NAMESPACE__ . '\deactivate_on_front_page' );

Disable LazyLoad on Blog Page

The blog page of your site is the one displaying an archive of your recent posts. It can be the front page, or any other page you have set to display such archive in Settings β†’ Reading β†’ Front page displays.

function deactivate_on_blog_page() {
	if ( is_home() ) {
		add_filter( 'do_rocket_lazyload', '__return_false' );
	}
}
add_filter( 'wp', __NAMESPACE__ . '\deactivate_on_blog_page' );

Disable LazyLoad on Single Posts

A Single Post is the page you see when you open the permalink of a post. The required function is included in the plugin.

Disable LazyLoad on WooCommerce Product Pages

A Product Page in WooCommerce is the page you see when you open the permalink of a single product. The required function is included in the plugin.

Note: As you can see, only one line of code changes in the above samples. The functions used in those lines are called Conditional Tags. To learn more about Conditional Tags in WordPress, check out the official Theme Handbook:
Conditional Tags