Some people asked for documentation/ information on that new autoptimize_filter_imgopt_lazyload_from_nth filter which allows one to tell AO not to optimize the first X images found in the HTML, so here is an example code snippet that sees AO not lazyload the first 5 images:
add_filter( 'autoptimize_filter_imgopt_lazyload_from_nth', function(){ return 5; } );
Update: as from AO 2.8.2 this will also be an option on the settings page, see screenshot 🙂
Hi Frank,
thanks for the explanation!
Where do I put this code?
Directly in the Autoptimize plugin or via snippets plugin?
Thanks
Heike
code snippets plugin indeed, but I’ll add it to the settings-page real soon (working on some small improvements for 2.8.1 now)
The setting is added in 2.8.1-beta-1, you can download the beta from from https://github.com/futtta/autoptimize/archive/beta.zip to test.
Hi Frank,
First of all, thanks so much for your great plugin.
When is it recommended to use this functionality?
Could you give an example of usage?
Thank you
Well, lazyload is great for images that are not visible yet, but ideally your above-the-fold images are not lazyloaded to avoid users having to wait long(er) on the image appearing. Telling AO not to lazyload the first X images found in the HTML (using the filter or now with AO 2.8.1 released the option on the images settings page) is meant to help doing just that; not lazyloading important images.
Thank you Frank 🙂
Great feature, great info and great plugin.
Cheers
Ylia