[Link to the mod](https://custom.simplemachines.org/index.php?mod=4259)
# Lazyload
Lazy loading for images displayed in SMF messages.
### Description:
This modification (for SMF 2.0 Final only) adds a feature allowing posts images to be loaded only when they are needed.
If an image is not in the display window, it is not loaded.
The display of a page thus becomes faster.
**_This feature is essential for mobile phones that are charged by the amount of data they consume._**
For more information on the JavaScript used, please visit the project's Github repository :
**[https://github.com/aFarkas/lazysizes](https://github.com/aFarkas/lazysizes)**
**[https://chez-oim.org](https://chez-oim.org) - _This mod is copylefted_**
To contribute : **[https://github.com/alexetgus/lazyload](https://github.com/alexetgus/lazyload)**
I had tried this a while ago and it works quite well for a while, out of nowhere I stop working it's time to try it again... Great job I will comment on anything!
Regards!
Holy ****** this is just what I needed google pagespeed insights always pings me on my images
would there be any updates to have lazyloaded avatars and board icons?
Yes it's possible, that's what I did on my site (images, avatars and smileys)
I only proposed the images, but I can create several versions of the mod according to the desires of each one.
There's no need to do it for board icons, it's the caching that does the job. No need for lazy loading.
Of course, one must be interested in the caching of the resources of its forum. This is a very important point!
Can you please tell me what did you put it in the code? I tried doing it last night but it failed. And I have level 2 cahcing but I have special board icons which google pagespeed insights tells me I should lazy load them.
Stop listening to Google like he's always right.
This is often wrong and it will not harm your SEO!
For avatars, look in the file Load.php, Display.template.php et MessageIndex.template.php
For smileys, it's in the file GeneriControls.template.php
And stop listening to Google! He's not always right...
If you keep listening to him like a schoolboy, you'll do something stupid!...
Hi,
Just for your information.
If you want to add images lazyloading to your forum directly into the PHP code, load the javascript ./Themes/default/scripts/lazysizes.min.js, if you haven't already done so, and display your image like this:
<img data-src="my-image.png" class="lazyload" />
!!!ATTENTION!!!
Version 2.0 fixes the XSS security flaw CVE-2020-7642 (https://github.com/advisories/GHSA-hg2p-2cvq-4ppv) in the aFarkas/lazysizes JavaScript
This flaw was detected less than 24 hours ago.
The risk is low, but remember to update!
Mod filename is 'lazyload-2.0.zip' but mod version in 'package-info.xml' is 1.1 ...
thank you for this
I looked it over, as far as I can tell the only thing to do to update is just replace the js file, correct?
Yes, that's exactly it. Just replace the JS.
@GL700Wing Oops! :-[
That's it, it's fixed. ;)
@alexetgus ??? Is there any chance to upgrade this to 2.1.x?
Regards!