• Resolved JMan

    (@jrobertse)


    Not sure how it is related but with testing and the devs of Spectra helping investigate. The native loading of images is being removed on Spectra’s Post Grid block and a few others when Simply Static is activated. See video URL showing when plugin is activated and deactivated how it is not there and then there after Simply Static is put off. Video is in the link to page I need help with.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author patrickposner

    (@patrickposner)

    Hey @jrobertse,

    It’s true – Simply Static turns off the native lazy loading because it doesn’t work in a static conversion process.

    We would need to use a headless browser (usually a paid external API) to make that work, as we can’t wait for elements during the crawling process via PHP.

    We turned off lazy loading when Simply Static is used to avoid missing image/video files on the static site.

    Cheers,

    Patrick

    Thread Starter JMan

    (@jrobertse)

    Cool, can you add it back via a script after or share a solution how please? It’s a crucial part to performance.

    Plugin Author patrickposner

    (@patrickposner)

    Hey @jrobertse,

    you can easily toggle it on again from the functions.php of your (child) theme with the following code snippet:

    add_filter( 'wp_lazy_loading_enabled', '__return_true' );

    I just wanted to mention that lazy loading doesn’t make sense in a static site setup (at least not controlled from within WordPress) as it:

    1. Slows down the rendering of a static site (it’s slower)
    2. It may causes errors when crawling the page (missing assets)

    It’s pretty much the same when using a caching plugin in combination with Simply Static – it introduces problems with little to no benefits.

    I don’t want to say that lazy loading is bad (it’s a great concept), but it rarely provides the same benefits to a static site as to a WordPress website.

    Thread Starter JMan

    (@jrobertse)

    I can’t seem to add that code, it won’t accept it. Also tried via code snippet and it doesn’t work even though it is accepted. So your plugin isn’t removing it everywhere and where it isn’t removed it works great. Not sure why it would have a problem with your plugin as it would still get the image via URL in the HTML.

    Lazy load is for below the fold, regardless of it being a static site, it still loads the LCP and FCP faster, then loads the rest as they scroll. Its a great benefit to load.

    Can you perhaps add an option on the plugin to include or exclude lazy load?

    Plugin Author patrickposner

    (@patrickposner)

    The filter might trigger too early. If added to the child theme, you may have to wrap it into the correct hook like so:

    add_action( 'after_setup_theme', function () {
    	add_filter( 'wp_lazy_loading_enabled', '__return_true' );
    } );

    I’m sadly not having the time to explain all the concepts here in the forum support, and I also don’t want to start a discussion on performance optimization.

    So let’s focus on fixing the problem, shall we? ??

    The code above should disable the lazy loading filter in Simply Static.

    However, if the markup of your theme isn’t supported (custom data attributes, for example), you (or your developer) may have to extend the tags that we use to parse the images with the filter described here: https://simplystatic.com/docs/hooks-filter-simply-static/#ss-match-tags

    Thread Starter JMan

    (@jrobertse)

    100s, thank you very much, this works for me now.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Simply Static is removing native lazy load’ is closed to new replies.