-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.0] Implement loading=lazy for images #28838
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not familiar with Joomla, but the implementation here looks solid, also in terms of covering the common cases I would expect to be covered (images being output via dedicated function or as part of "content blob"). 👍
But what about loading=lazy for iframe? |
Sounds interesting. Will take a closer look into the implementation my main concern would be that nowdays you should not use iframes that much any more right? Do you know wether there are possible side affects by adding that loading to iframes? |
@viocassel @zero-24 While I think |
Thanks for you input on that @felixarntz extending the plugin is easy when there is a final specification out for sure. |
Please, please don't use experimental features: |
Will this not conflict with https://extensions.joomla.org/extension/photos-a-images/images/imagelazyloading? E.g if:
|
No it is a different extension name. |
plg_content_imagelazyloading vs plg_content_imagelazyload ;-) |
I have tested this item ✅ successfully on d36505f This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28838. |
I have tested this item ✅ successfully on d36505f This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28838. |
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28838. |
Thanks for all the feedback and the tests beeing done here 👍 |
I'm really in favor to use the loading attribute. But why adding another plugin? We can just change it in the layouts to use the loading attribute and then it can be overridden when required. Every plugin has negative impact on page load so we should choose it wisely. Just my 2 cents here. |
By using a plugin everyone can disable that feature and we are not hardcoding a feature in com_content as well as this works for all extensions that fire the onContentPrepare event. |
I also don't see why this would be needed. Even for upgrades, the site will work just fine without that lazy loading attribute. For those who don't care, the lazy loading doesn't matter and the impact it has will be nothing since they likely have far bigger issues to solve. |
On which approach? To inform the user after Joomla got upgraded to 4? Yes sure, you can add there a whole summary of performance optimization suggestions. I do not care. What I care is that there is no need for a plugin. |
I think that's not true. Anyway... I'm in favor for a Joomla managed component that does such "optional" things on upgrade, I'm sure there are more things that can be done after upgrading to j4 a more or less migration component (even if we don't need it for j4 upgrade). Which could be installed by a post upgrade message or by pointing to JED. On the other side we see how good com_weblinks is maintained... |
This has nothing todo with this plugin than right? It is more a general thing that should be discussed in in a different issue i guess. Btw is that 30% a real number or just a feeled number? Yes we have more plugins but for the site load we have the following right now: Content 3.x 10; 4.x 11 (with this plugin included) As for the system plugins it is that most of the new of them are not running on all sites or have sesible defaults to skip early on the site nor have a that bad impact. What other pluigins influence the inital page load? Sure we added a lot for media manager and webservices but they usually not run on events that Influence the intial page load right? |
I wouldn't make such a comment without backing it with some hard data, and yes Joomla is failing hard to deliver competitive sites: https://joomla-needed-fixes.netlify.app/data/ (this is all of the showcase sites with most of them still running on HTTP instead of HTTPS, having a blank page for more than 3 seconds before anything is painted, etc) Sorry that's the hard truth 😞
Oh yes, it's very real, count ALL the plugins. |
Yes that is the point what speaks against moving that to the most sites by default? I guess you all saw that post of the motivation behind lazyloading and that images are the things that are consuming the most resouces on pageload as well as on the servers. So i would like to turn the questions why should we not do that? As it improves the Performance for all sites with nearly zero costs for us nor the site owner. The reality is most of them don't care about all that that's the reason i think we should come up with good defaults thag can be disabled by the people that do have issues with it. So the general people can stop claming 'joomla is bad for performance because they dont do layzloading' like they do for other things we dont do. It is something that is build in native in the browsers not a JS lib with a gazillion depentecys right? |
NO, you're wrong here. The problem is the excessive CSS (bootstrap and font awesome) and all the JS that is not deferred. These are RENDER BLOCKING meaning the visitor of the site stairs on a blank screen until these are downloaded, parsed and executed. Images are not render blocking thus the only negative effect is their size, which by the way |
https://web.dev/native-lazy-loading/ This is what i'm talking about. @dgrammatiko We don't fix all issues with it for sure but we can make a good step in the right direction for all users of Joomla. |
The |
Agree what about starting an RFC on your proposed pluigin and with your permission we build a core plugin based on yours. You don't have to do the coding when you don't want to. But starting the discussion would help. I for example was not aware of that plugin. |
I've had a chat with @zero-24 about this offline and have agreed to merge this (it was my idea to only have it enabled for existing installs). I do understand the cons of performance here. And definitely we should be advocating for people to fix this properly in the database. But I don't think it's realistic to believe that the majority of people will do this either. |
@wilsonge even the googler devs were against this: GoogleChrome/lighthouse-stack-packs#44 (comment) Also do you realise that I already have:
You want to have them under Joomla because you don't trust me? Fork them, their OSS |
No it was the google devs suggestion. Tobias was the one interacting with them so I think he knows best what they were suggesting |
@wilsonge probably it's my bad English but even Tobias responds that the plugin will be the first on the search. So it wasn't their suggestion at any point |
Sounds interesting. Will take a closer look into the implementation my main concern would be that nowdays you should not use iframes that much any more right? Do you know wether there are possible side affects by adding that loading to iframes?How can this be implemented for an iframe? This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28838. |
That plugin has been reverted out of the core before the final release was made. Please find here more details about lazy loading iframes: |
Pull Request for Issue #27761
Summary of Changes
As discussed here: https://volunteers.joomla.org/departments/production/reports/1226-production-dept-meeting-april-21-2020
We are now even official allowed to introduce featues like this here that don't break existing sites and just improve the overall expiricece for people using modern browsers.
Feature
This PR sets the lazyloading attribute to all images that passes the onContentPrepare Event or HTMLHelper::image to allow modern browsers to lazyload the images.
More information about the
loading
attribute:loading
attribute is supported in the following browsers: https://caniuse.com/#feat=loading-lazy-attr.Testing Instructions
Expected result
Joomla by its core can set the loading=lazy attribute to images.
Actual result
Joomla can not set that loading=lazy attribute.
Documentation Changes Required
A doc page will be produced on this, I have just added the label and assigned it to me.
Beyond this PR
There is a backport of this feature / plugin for Joomla 3 here: GitHub JED
Special thanks
Thanks @SniperSister and @felixarntz for your support on that PR.