Lazy Load [img]

Lazy Load [img] 2.8.0

No permission to download
Hi, we've noted that this addon seems to explicitly disable lazy loading of images in the first post of a page when they are within the content window on load. Is that by design, and if so can it be force enabled somewhere? I had someone post a first thread recently with ~750 images within a spoiler tag that makes it onto the content window (We don't generally recommend even 1/4 this amount of images in a single post, but since when do users listen?) and, uh, you can imagine the problem from there. We do already have the option checked for lazy loading images in spoilers, and I've confirmed it does behave as expected for posts that aren't in view when the page loads. Disabling this addon on the page in question improves page load time in this particular instance from like 8 seconds to ~700ms because it's no longer trying to fetch all those images.
is the loading="lazy" added to the image tag? i think this out of the box has limitations.
 
Make sure the Enable Lazy Load Images permission is granted. If you have wonky permission setup, this might not be applying to all users as by default it is only granted to the regular users group.
 
Make sure the Enable Lazy Load Images permission is granted. If you have wonky permission setup, this might not be applying to all users as by default it is only granted to the regular users group.
Ah...yes the permission was set correctly...for members, but the person reporting it was viewing as a guest. I did not realize it didn't apply to guests by default (or maybe we set it that way a while ago, ignorant of the effects it would have). Thank you for clearing that up.
 
@Xon is this addon still relevant since lazy loading was implemented in XF 2.2?
 
This add-on basically ends up being a permission to disable lazy loading. I'll probably mark this add-on as deprecated this year.
 
Hi,

I think I found an issue with the "Lazy load icons" option on XenForo 2.3. XenForo 2.3 already adds loading="lazy" to custom avatar images in XF\Template\Templater::fnAvatar():

PHP:
width="' . $pixels . '" height="' . $pixels . '" loading="lazy"

However, SV\LazyImageLoader\XF\Template\Templater::injectImgLazyAttribute() removes that attribute whenever $hasNativeLazyLoading is true:

PHP:
$url = str_replace('" loading="lazy"', '"', $url);

fnAvatar() passes \XF::$versionId > 2020000 as that argument, so on XenForo 2.3 this condition is always true. As a result, with both "Lazy load icons" and "Use native lazy loading" enabled, rendered user avatars no longer contain loading="lazy". I confirmed this in the rendered HTML. An avatar near the very bottom of the page is output as:

HTML:
<img src="..." srcset="..." width="48" height="48">

There is no loading="lazy" attribute. On the same page, I see roughly 170 image requests immediately after loading the page at the top. After scrolling all the way to the bottom, the total only increases to around 179 image requests. Could you please check whether removing the native loading="lazy" attribute here is still intentional for XenForo 2.3? The current behavior seems to effectively disable lazy loading for user avatars.
 
Back
Top Bottom