Aleš Sýkora / January 21, 2021 / 0 comments
Change WP Rocket lazyload treshold
min read / WordPress / Share on: Twitter, LinkedIn, Facebook
Post summary: Default treshold for lazyload is 300px in WP-Rocket. That means that images that are within 300px of the viewport (browser window) are loaded for smooth user experience. If you like to load less images – for example 100px after viewport only – you can not set it up directly in WP Rocket’s settings page. To…
Default treshold for lazyload is 300px in WP-Rocket. That means that images that are within 300px of the viewport (browser window) are loaded for smooth user experience.
If you like to load less images – for example 100px after viewport only – you can not set it up directly in WP Rocket’s settings page.
To adjust WP Rocket Lazyload treshold, you need to use this filter:
function rocket_lazyload_custom_threshold( $threshold ) {
return 100;
//height in pixels
}
add_filter( 'rocket_lazyload_threshold', 'rocket_lazyload_custom_threshold' );
Put it in your code snippets, custom funcionality plugin or to functions.php i your child theme.
Fuel my passion for writing with a beer🍺
Your support not only makes me drunk but also greatly motivates me to continue creating content that helps. Cheers to more discoveries and shared success. 🍻