• Welcome to Simple Machines Community Forum. Please login or sign up.
January 17, 2022, 09:56:14 PM


Want to get involved in developing SMF, then why not lend a hand on our github!


Started by alexetgus, April 25, 2020, 04:06:56 PM

Previous topic - Next topic


Link to the mod


Lazy loading for images displayed in SMF messages.


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://chez-oim.org  -  This mod is copylefted To contribute : https://github.com/alexetgus/lazyload

-Rock Lee-

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!

¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!


Holy ****** this is just what I needed google pagespeed insights always pings me on my images
Welcome to Agora Road's Macintosh Cafe || A retro design vaporwave community forum! Enjoy your stay!


would there be any updates to have lazyloaded avatars and board icons?
Welcome to Agora Road's Macintosh Cafe || A retro design vaporwave community forum! Enjoy your stay!


May 10, 2020, 04:02:20 AM #4 Last Edit: May 10, 2020, 04:40:58 AM by alexetgus
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.
Welcome to Agora Road's Macintosh Cafe || A retro design vaporwave community forum! Enjoy your stay!


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!...



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" />



Version 2.0 fixes the XSS security flaw CVE-2020-7642 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 ...
Life doesn't have to be perfect to be wonderful ...


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.


Oops! :-[
That's it, it's fixed. ;)