Disable LazyLoad for iframes

When the LazyLoad for iframes and videos feature causes problems to the iframes, you can opt for disabling it on specific iframes, pages or programmatically.

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.


<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.