Aleš Sýkora wrote

Change WP Rocket lazyload treshold

21. 1. 2021 in

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

More from category
Aleš Sýkora wrote
Best practise for jQuery in Toolset
3. 7. 2019 in
Let me explain best practices for using jQuery inside a View, Form or Content Template's JS panel.
Read More
Aleš Sýkora wrote
Change GDPR field response data in Fluent Forms
15. 4. 2021 in
If you want to change the “Accepted” to something else, use the first snippet and change the $response variable. If you want to change the Terms and Condition and GDPR field response, use this code:
Read More
Aleš Sýkora wrote
Fix WooCommerce coupon input in Oxygen
9. 4. 2021 in ,
The field for adding coupons in WooCommerce cart is horrible in Oxygen. If you want to fix it from: Before: After: Then feel free to use and edit my CSS:
Read More
magnifiercross linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram