Disable LazyLoad for Iframes

In this Article

Disable LazyLoad on Specific Iframes

There is a field in the plugin settings to exclude iframes from LazyLoad:

To exclude an iframe use any keyword from the <iframe> element code.

Example

<iframe title="Introducing RocketCDN - WP Rocket CDN Service" width="580" height="326" src="https://www.youtube.com/embed/LtU76BZcRQk?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

To exclude this iframe you could use any of the following: 

  • The title:Introducing RocketCDN
  • The embed source: https://www.youtube.com/embed/LtU76BZcRQk?feature=oembed
  • The domain: youtube.com - this will exclude all iframes from youtube.com

Disable Iframe LazyLoad on Specific Pages

Follow the guide here to disable this option on particular pages.

Programmatically Disable Iframe LazyLoad

To programmatically disable iframe LazyLoad on certain types of pages you may use this filter:

add_filter( 'do_rocket_lazyload_iframes', '__return_false' );

For example, to disable LazyLoad on only WooCommerce single product pages you could use the following snippet:

function rocket_lazyload_deactivate_on_single_product() {
	if ( is_singular( 'product' ) ) {
		add_filter( 'do_rocket_lazyload_iframes', '__return_false' );
	}
}
add_filter( 'wp', 'rocket_lazyload_deactivate_on_single_product' );
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.