Add loading='lazy'
to the Product Image block. Especially in need when used within the Products (loop) block.
#9115
Replies: 6 comments 1 reply
-
Thanks @asafm7 for starting this discussion! To give more context and confirm, that option would allow for optimization, so the images that are outside of the viewport, won't be loaded until necessary. That's especially useful in the mobile view, where the products are usually stacked on each other, so by default you see just 1-2 products, not let's say 10. Hence the image loading could be optimized. I like the idea, however, I don't think that should be added to each of them. Rather than that, I believe that could be an option in the Inspector Controls whether the Product Image should be lazy loaded with the option disabled by default. Users could then enable this option in a particular place, for example within the Products block. The feature has pretty nice browser coverage as well: Can I Use. I'm happy to hear others' opinions, cc: @imanish003, @shaunandrews, @Aljullu - do you see any obstacles for that? Ref issue: https://github.com/woocommerce/woocommerce-blocks/issues/9248 |
Beta Was this translation helpful? Give feedback.
-
Thanks, @kmanijak . I believe Unless I'm wrong, there shouldn't be any downside to enabling it by default to all images, and the implementation is easy (just adding an HTML attribute) |
Beta Was this translation helpful? Give feedback.
-
Thanks for starting this discussion, @asafm7! This is indeed a very interesting topic and which might have a significant impact on page load performance as well as bandwith usage. In order to implement this, I think it's worth reading WP's findings when they did something similar in WP core: https://make.wordpress.org/core/2021/07/15/refining-wordpress-cores-lazy-loading-implementation/ What they ended up with: adding So I think we have two approaches here:
I would lean towards option 1 for simplicity and we can refine in the future.
I'm not convinced about having an opction for this. 🤔 The reason is that I won't expect users to know what's the best value for this setting, so ideally we should make the decision for them IMO. However, it looks like WP core has some PHP filters for that which I think we should support. That would allow advanced users to tweak the behavior without the UI getting cluttered. Regarding the urgency of this, IMO this is something that can be worked on after the Products block is out of beta. While it sounds like a nice performance improvement, I don't think it is a blocker. |
Beta Was this translation helpful? Give feedback.
-
BTW, maybe I'm missing something, but as the Products block utilities the Featured Image block, which is independent - isn't more a Featured Image block issue rather than the Products block? |
Beta Was this translation helpful? Give feedback.
-
Thanks @Aljullu . Yes, that's what I meant. Sorry for the confusion. So, should we move the ticket, re-tag it or re-open it elsewhere? |
Beta Was this translation helpful? Give feedback.
-
Product Image is the block from WooCommerce Blocks repo, so no need to reopen or retag the issues. https://github.com/woocommerce/woocommerce-blocks/issues/9248 is fine in its current shape.
Same here, I would keep it simple. Considering the discussion above I think we agree that it would be a good move to lazy load the Product Image, but that's not the highest priority for now. I'll go ahead and close this discussion now (remember that it can be still commented on) and let's stick to the issue https://github.com/woocommerce/woocommerce-blocks/issues/9248. I'll write an update there as well 🙌 |
Beta Was this translation helpful? Give feedback.
-
Add
loading='lazy'
to the Product Image block. Especially in need when used within the Products (loop) block.Beta Was this translation helpful? Give feedback.
All reactions