-
Notifications
You must be signed in to change notification settings - Fork 20
Consider changing or removing wp_get_lazy_load_tags() #5
Comments
I would vote for the second option as it does no harm and makes it easier to update in the future, should more tags support lazy loading. |
Second option seems inline with expectations regarding how WordPress interacts with HTML By exposing a global function for plugin authors to use inside their own contexts, they do not need to replicate and maintain a core filter in their own plugins. |
I also think the second option is more applicable because of easier maintenance and future compatibility. If iframes are not supported, all we need to do is remove them from wp-lazy-loading/wp-lazy-loading.php Line 105 in e16ec07
Any tag that gets supported can be added to that list in the future. The counter-argument would be that having flexible tags here would make #2 more complicated, which is fair, especially where we are now with only one specific element supporting the attribute (if that is the case - we still don't know yet for sure). |
Thanks for the feedback, everybody :) Thinking that both points make sense and ideally should be implemented. The current At the moment For more fine-grained control thinking that having a filter for each image (and eventually iframe) would be best. That will make it possible for plugins to handle the exceptions and other cases mentioned in #4. |
That's a good point. 👍 |
PR: #7. |
Follow up from #3.
PR: #7.
Seems that iframes will not support the
loading
attribute for now. Support will be added in the future.Generally this would mean refactoring or even dropping the existing
wp_get_lazy_load_tags()
. It may be "nice to have" a way to globally disable auto-adding of that attribute on the front-end, but not sure that's needed. Ideally there should be a way to change/disable it on per-case (per-image) basis that is also "simple enough" to use to globally disable it in all cases.As far as I see there are couple of ways to do that:
<img>
tag, and passes some context where that tag is. This will also allow plugins to "fine-tune" where the attribute is added and/or make it conditional on the context. Possible downside is that such filter will be quite "noisy". It will run anywhere form 10-15 times up to few hundred times per page load (in case of big galleries, etc.).wp_get_lazy_load_tags()
as a "wrapper" function that will only run the'wp_get_lazy_load_tags'
filter (similarly to how it works now but without support for iframes). In this case it can be extended in the future when iframes start to support the "loading" attribute. Ideally it should also pass some context, for examplecurrent_filter()
or a hard-coded value when it is called "by hand" like fromget_avatar()
, etc.The text was updated successfully, but these errors were encountered: