Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: alexetgus on April 25, 2020, 04:06:56 PM

Title: Lazyload
Post by: alexetgus on April 25, 2020, 04:06:56 PM
[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)**
Title: Re: Lazyload
Post by: -Rock Lee- on April 25, 2020, 06:00:59 PM
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!
Title: Re: Lazyload
Post by: DreadPirateRoberts on May 04, 2020, 12:50:46 AM
Holy ****** this is just what I needed google pagespeed insights always pings me on my images
Title: Re: Lazyload
Post by: DreadPirateRoberts on May 10, 2020, 03:23:10 AM
would there be any updates to have lazyloaded avatars and board icons?
Title: Re: Lazyload
Post by: alexetgus on May 10, 2020, 04:02:20 AM
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!
Title: Re: Lazyload
Post by: DreadPirateRoberts on May 10, 2020, 02:34:41 PM
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.
Title: Re: Lazyload
Post by: alexetgus on May 11, 2020, 10:25:03 AM
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!...
Title: Re: Lazyload
Post by: alexetgus on September 19, 2020, 06:56:53 AM
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" />

Title: Re: Lazyload
Post by: alexetgus on December 11, 2021, 01:19:05 PM
!!!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!
Title: Re: Lazyload
Post by: GL700Wing on December 14, 2021, 06:57:24 AM
Mod filename is 'lazyload-2.0.zip' but mod version in 'package-info.xml' is 1.1 ...
Title: Re: Lazyload
Post by: shadav on December 14, 2021, 12:50:31 PM
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?
Title: Re: Lazyload
Post by: alexetgus on December 14, 2021, 01:13:49 PM
Yes, that's exactly it. Just replace the JS.


@GL700Wing

Oops! :-[
That's it, it's fixed. ;)
Title: Re: Lazyload
Post by: -Rock Lee- on March 23, 2022, 10:29:34 PM
@alexetgus ??? Is there any chance to upgrade this to 2.1.x?


Regards!