Search
Other Modals questions
Forum

suggest/wish for future versions: loading="lazy" for the thumbnails

Dirk67's Avatar Dirk67
this is just a suggest/wish for a future (J4) version of Modals:

I experimented with (browser based) "native lazy loading" for the <img> tag of the thumbnails
( <img loading="lazy" alt="" src="..." > )
( good explanation here: web.dev/browser-level-image-lazy-loading/ )

This can be useful in some scenarios especially in the gallery use-case of modals
where I have huge galleries with a lot of thumbnails (100+) on a single page.

For users with poor internet bandwidth (e.g. mobile use) it speeds up the page load ("first rendered impression") a lot with modern actual browsers...
(only the very few images that are visible in the viewport are loaded first)

As a quick "hack" I just added a one-liner to the file ".../plugins/system/modals/src/ImageTraits.php":
$this->attributes->loading ='lazy';
and was able to test it this way.

-------

so my suggest/wish for a future (J4) version of Modals would be
to make a setting in the backend to switch on/off this additional lazy-load attribute for the thumbnails,
or maybe just for the gallery mode (?)
Peter van Westen's Avatar Peter van Westen ADMIN
I'll keep it in mind. Give me a shout out once Modals for Joomla 4 is released (won't be very soon), and it isn't in there yet.
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription