Support » Plugin: Autoptimize » Question about lazy loading

  • lozula


    Quick question about lazy loading.

    The lazysizes script in autoptimize has a number of plugins that extend the functionality, as seen here:

    Most useful in my mind are the aspectratio plugin, which saves the screen jumping around when images lazy load, and the unveilhooks plugin, which lets other elements lazy load, most notably background images.

    I’m not sure if adding these as an option might be in scope (I appreciate feature creep might become an issue). Otherwise, I am wondering if you have any thoughts as to the best way to add them myself somehow in a way that works with AO.

    Thanks as always for a great plugin!


Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Optimizing Matters


    don’t have in-UI support for 3rd lazysizes plugins at this point (and feature creep wise I indeed cannot promise they will get in there), but *I guess* enqueuing those (in footer) should work? if not I could always add a filter (action) hook to hook into after the main lazysizes JS is declared?




    The docs for lazysizes (


    It is recommended to concat all plugins together with lazySizes. In case you don’t concat it is recommended to include the plugin scripts before the lazySizes main script.

    If AO is optimizing and combining all scripts, I guess that would have the same effect as the first option if I put them in the footer?

    Plugin Author Optimizing Matters


    well, by default lazysizes is excluded from JS optimization (as we want to images to appear asap instead of waiting for deferred JS) and asynced, but you can change that with this filter;


    alternatively you could enqueue the 3rd party lazysizes plugins in head, in which case they indeed are most certainly loaded before lazysizes itself?


Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Question about lazy loading’ is closed to new replies.