Closed (won't fix)
Project:
BS Base
Version:
8.x-1.x-dev
Component:
BS Bootstrap
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
10 Jun 2019 at 10:29 UTC
Updated:
18 May 2021 at 13:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
pivica commentedHere is a first patch.
Comment #3
miro_dietikerIt would be really nice to have either a description is provided or a link to specifications. Lazy, Eager, Auto all is not clear to the regular uninformed user. / site builder.
And then we should state what expectedly supports this as well in the UI as a disclaimer. ;-)
SVG? :-)
And those are actual integration to specific contrib modules, so we should put a reference in the comment.
Thought this would affect all iframes until i have seen that it only affects video_embed cases.. I don't know if you really want to have such a generic setting and later expand it to affect more iframes?
Also not fully sure how this works combined with GDPR postponed loading-on-click features.. And script based iframes?
So maybe this is really video_embed specific?
Comment #4
sasanikolic commentedNote that this (for now) only works in Chrome and Android browser: https://caniuse.com/#search=lazy-loading
For Firefox an issue was created, but no priority was defined yet: https://bugzilla.mozilla.org/show_bug.cgi?id=1542784
Based on the previous feedback, changing the status. Will test it soon.
Comment #5
pivica commentedComment #6
pivica commentedComment #7
pivica commentedHere is a new patch.
> It would be really nice to have either a description is provided or a link to specifications.
Added.
> Lazy, Eager, Auto
It seems auto is not an option any more so i've removed it.
> And then we should state what expectedly supports this as well in the UI as a disclaimer. ;-)
You are referring to browser support or?
> SVG? :-)
Why not? If it is coming from img tag i guess it makes sense right? I improved patch to work with SVG only when it is not inlined.
> And those are actual integration to specific contrib modules, so we should put a reference in the comment.
Added comments related to this.
> Thought this would affect all iframes until i have seen that it only affects video_embed cases..
No just video iframes which are the most common case probably.
Media Twitter is using iframe but it is initialized on client-side - maybe we could pass optional loading parameter somehow, didn't check it for now. Same goes for media instagram - it is converted to iframe on client-side.
We will deal with iframes in the follow-up.
> Also not fully sure how this works combined with GDPR postponed loading-on-click features.. And script based iframes?
No idea, however how is this related to GDPR in this context? Here we are just changing when the resource will be loaded. I guess you could track scrolling of viewport with this to some degree - but that is very inaccurate because each browser has it own logic when it will decide to load some lazy resource.
Additionally, Drupal core changed media handling, for example youtube is now handled by oembed. Discussed this with @berdir and his proposal is to move iframe support to follow-up and that we should concentrate first on images.
Comment #8
pivica commentedUsed wrong attributes in link translation, fixed now.
Comment #9
pivica commentedComment #10
pivica commentedReady for a new review.
Created #3157699: Lazy loading of iframes follow-up for all iframe related issues.
Comment #11
sasanikolic commentedI see Mozilla defines it as "Eager", but maybe we should consider a different name, like "Normal", "Default" or something else? On the other hand I feel like we should stick to the definitions mentioned at https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-loading. I don't have a strong opinion about that, just an idea.
Maybe change "on this link" to "here".
iframe should be lowercase, as we're referring to the html element: https://www.w3schools.com/tags/tag_iframe.asp
Last, but not the least, note that this will not work in older Firefox, Firefox for mobiles, IE11, Safari: https://caniuse.com/#feat=loading-lazy-attr. Didn't check if there are some polyfills for those yet, should we just state that we don't support this functionality in those browsers as just yet? Safari should be fixed soon: https://bugs.webkit.org/show_bug.cgi?id=196698.
Comment #12
pivica commentedHere is a new patch based on the latest comment feedback.
> I see Mozilla defines it as "Eager", but maybe we should consider a different name, like "Normal", "Default" or something else?
Well, it's not Mozilla that defines it but the actual specification https://html.spec.whatwg.org/multipage/urls-and-fetching.html#lazy-loadi....
I do agree that 'Normal' or 'Default' would be a better fit, but it could create confusion if somebody actually visits documentation link read that there is an 'Eager' option which is not presented visually on settings form. So i would keep it 'Eager' for now.
> 2. and 3.
Done.
> Last, but not the least, note that this will not work in older Firefox, Firefox for mobiles, IE11, Safari...
Current iframe support is old and works only for contributed media module, it will not work for new media core solution. We have a follow-up for this on #3157699: Lazy loading of iframes - i've updated issue description with your feedback. We are also stating in the description that this feature is experimental for now, i guess that is enough for now.
Comment #13
berdirI'm unsure about keeping this at all.
The "new" feature is in core since 8.6, that's Sept 18.
It's also way less frequently used and much less of a concern IMHO.
this doesn't seem to match. false as default config, but type string?
Comment #14
pivica commented> 1. I'm unsure about keeping this at all.
Makes total sense, removed related code to #3157699-3: Lazy loading of iframes.
> 2. this doesn't seem to match. false as default config, but type string?
Saw that before, but was a bit too lazy to change it, i guess type casting worked fine. Anyway, make sense to fix this.
Found one additional bug, in settings get function key was lazy_load_img instead of lazy_loading_img.
Comment #15
sasanikolic commentedNote that lazy loading will be enabled by default in Drupal 9.1: #3167034.
However, I noticed that in their image preprocess function they have this:
We don't have any check like that, thus we're adding the lazy attribute also to responsive images, which doesn't happen when I remove this patch.
Comment #16
pivica commented> Note that lazy loading will be enabled by default in Drupal 9.1: #3167034.
Discussed with @sni, we do not like the fact that Drupal is doing this:
Because we think that these two things are not related. Lazy loading is one thing and setting width/height is another one - why should we not lazy loading image assets if width/height is not set.
Additionally, @sni is saying that this creates a problem with responsive images because the core is not setting width/height on the responsive image.
The only thing that we could improve is to do a lazy loading attribute empty check like core is doing like:
So lets do that.
Comment #17
berdirI'm not sure it's so unrelated. Lazy-loading on images without a predefined width/height might result in layout adjustments as the image gets loaded, I would assume that's the reason for that.
But yes, without doing it for responsive images, it's missing out on the main use case.
Comment #18
pivica commented> Lazy-loading on images without a predefined width/height might result in layout adjustments as the image gets loaded, I would assume that's the reason for that.
I do agree that that is the reason they added that checks, however, I don't think that this should be default behaviour - if no w/h then disable lazy loading. For some people, it would still be better to lazy load these resources when/if needed then to always load them.
Additionally, I would treat any image that is coming from image styles and has missing w/h or any other manual image without w/h as a bug.
Two more things.
1. Lazy loading attribute works also for iframes, and we have an idea to support youtube/vimeo and similar iframes that are coming from media. We would need separate settings for that.
2. We are offering option here for lazy loading which can be disabled if needed and user wantsthat, the core is not doing that for now.
Comment #19
pivica commentedAnd a third thing, we also support lazy load attrib for SVG images with img tag, not something that core is doing.
Here is a patch that adds a check like core is doing.
Comment #20
pivica commentedComment #21
pivica commentedCore introduced lazy loading of images which is turned on by default in #3167034: Leverage the 'loading' html attribute to enable lazy-load by default for images in Drupal core. There is no point for this patch any more.