-
Notifications
You must be signed in to change notification settings - Fork 21
Conversation
Add missing test scenario back and remove duplicate line.
…ata-skip-lazy (as attribute) are set.
Frankly not sure if this belongs in core. I understand there is a push to use There are also certain differences between the js method (enforcing late loading of images) and the tag attribute which is just a hint for the browser that the image is suitable for lazy-loading. Generally the browser is "better equipped" to make a good decision how far below the fold to start loading images, can look at network/download speed, etc. In that terms thinking that there are benefits of having the attribute even on images with Thinking that the best solution would be to have a filter when adding the attribute to each |
Instead of not adding the |
Yeah, ideally plugins that add js based lazy-loading would "standardize" on using the The addition of the Also, the above point about the browsers being better equipped to determine when to start loading images means that some images that currently need In that terms thinking that WordPress core should not use/depend on things that may have been added by plugins. Instead, it should facilitate/make it easy for plugins to reuse or "fix" their previous methods. Generally this means that when a plugin has determined that a particular image is not suitable for lazy loading, it should add In cases where Then on the front-end lazy-loading plugins should be looking for the HTML attribute and immediately load images that don't have This means that pretty much all lazy-loading plugins will need updating to work well in WP 5.4. The sooner that starts, the better. The plan is to get this feature plugin to a usable state and release it as fast as possible, then try to popularize it so it can be well tested before merging to core. Would be ideal if the authors of lazy-loading plugin participate in both the testing and the development :) |
Agreed. I think now that there is a dedicated attribute for lazy-loading, for a core implementation only that attribute should be relevant to "skip" images. Core's implementation should be that Classes or data attributes are non-standardized workarounds for which the |
I'm afraid that in spite of "browsers know best" and "plugins would 'standardize' on using the loading attribute" in reality things will break for some users when this ships in core for many a reason. This probably will not be a problem for plugins that also implement lazy-load (I tested and all works at least for my plugin without any change needed) but rather for JS-heavy plugins that handle images somehow, thinking of sliders & gallery plugins for example (I've seen some weird stuff already). If the solution for things breaking once this ships in core is "wait until plugin X updates" or "use a filter", then I'm afraid we'll frustrate many end-users, so the question is how can we help those. An option to disable native lazy-loading is not an option (I'm all for smart defaults), but at least being able to end-users to add a class name ( Summary: it's about end-users, not plugin developers ;-) |
@futtta Could you clarify what type of breakage your concern is specifically? Since the |
One example from the top of my mind; I've seen plugins that use JS to get the dimensions of an image to act on that (I think for layout purposes). If an image is lazyloaded (natively or JS-wise), getting dimensions fails and the image display is broken. As I wrote; there's some crazy stuff out there ;-) |
Lazy loading of images is the kind of enhancement that end users should not need to think very much about. Just like the way themes come with decent SEO, there will be people who want to take that to the next level, and that should be allowed. Adding the ability to manage a new img attribute will require exposing a UI specifically for it beyond just a class, and that seems beyond the scope of this plugin and feature to me, though it certainly should be allowable for a plugin to create its own UI and support this. (Anchors already have/had support for the target attribute, and that has come up numerous times for removal from folks who forget how useful it is, simply because it is a bespoke anomaly of a UI.) |
Having UI to manage the attribute instead of using an exclusion class-name is great, but given lazy-loading is planned for inclusion in WordPress 5.4 (release March 31th) and as this feature-plugin is meant as a path to iterate towards core inclusion, shouldn't this be considered here, earlier rather then later? Or will this ship default on without any possibilities for average users to alter the behavior in case of issues? |
Probably, and we are considering it together. I just happen to feel like a UI isn't necessary. 😄
We get to decide this together, probably here, and possibly in Slack chats (though I'd prefer no decisions be made there for synchronicity reasons.) |
I'm on board with @JJJ and @felixarntz here :)
Exactly! It should "just work". The users shouldn't care about having to "micro-manage" it. Looking at the discussions on the specs: whatwg/html#2806 and whatwg/html#3752, all of the possible (edge) cases seem well covered. In addition we're making this WP plugin so it can be tested "in the field" with existing content.
I believe this is handled by the browser downloading the first 2KB of the image file (when the image will be lazy-loaded). That way the browser can get the (intrinsic) size and reserve appropriate space for the image. Seems that the same ensures the image dimensions will be available in js. Worth a test, but I see it discussed in the specs. #10 implements a |
My 2c: assuming no issues will arise and hence deciding end-users need no functionality to stop the loading attribute from being added is a big gamble. It might work out (yay), but I for one would not want to have to support people for whom it does not. Let's hope the feature plugin gains enough traction before this goes into core default on with no straightforward way for end-users to disable it :-) |
@futtta fwiw, I do appreciate your alternative point of view and perspective. You may be correct, and there may be feedback from users who wish to disable this. I can imagine scenarios where plugins or themes may want to opt in-or-out of it, like with what happens already with I can imagine wanting to skip it on a per image basis. I can imagine a piece of meta-data connected to something in the media library to prevent an image from ever lazy loading. The nuance with a feature like this, and with WordPress core, is deciding how small of a footprint will make the biggest impact from release to release; a smart default with flexible overrides. One or all of the above ideas may end up in core, and you’d be justified in saying “hey @JJJ I told you so” when they do. 😁 |
Thinking this should be closed for now in favor of specific (edge) cases that may require considering in WP core. One such case could be the presence/absence of
in the browser console while testing. |
Ensure that loading="lazy" is not set if skip-lazy class or data-skip-lazy attribute are set.