News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Lazyload

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

Previous topic - Next topic

alexetgus

Link to the mod

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://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!


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

DreadPirateRoberts

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!

DreadPirateRoberts

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!

alexetgus

#4
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!

DreadPirateRoberts

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!

alexetgus

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

alexetgus

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


alexetgus

!!!ATTENTION!!!

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!

GL700Wing

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

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

shadav

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?

alexetgus

Yes, that's exactly it. Just replace the JS.


@GL700Wing

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

-Rock Lee-

@alexetgus ??? Is there any chance to upgrade this to 2.1.x?


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

Advertisement: