Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to load all images after 2 seconds in lazysizes?

I am lazy loading images on the page, using the lazysizes library I call the script at the beginning of the page

<script> (function(){ window.lazySizesConfig = { lazyClass: 'lazy', loadMode: 2, hFac: 10, }; }); </script>

But the question arose, how to make it so that after loading the page, after a couple of seconds, all the pictures on lazy loaded without waiting for the page to scroll?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I couldn’t find a suitable parameter in the documentation, or I don’t understand something

>Solution :

You can manually run through all your elements and load them using unveil method

setTimeout(
    function () {
        $('.lazy').each(function () {
            lazySizes.loader.unveil($(this)[0])
        });
    },
    2000
);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading