ui5-webcomponents icon indicating copy to clipboard operation
ui5-webcomponents copied to clipboard

Image lazy-loading with <img loading="lazy">

Open mauriciolauffer opened this issue 6 years ago • 2 comments

Is your feature request related to a problem? Please describe. There's a new native feature to lazy loading images in the browsers. Async loading could improve performance, especially when using images in lists and tables, in UI5 apps.

Describe the solution you'd like Whenever a control uses tag, it should add an extra attribute for lazy-loading. The best part is it has NO impact on older browsers, it's harmless to the ones which don't support it. The attribute will just be ignored and the image'll be loaded as usual (sync mode).

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Pretty much the same thing requested here: https://github.com/SAP/openui5/issues/3071

Example: img src="image.png" loading="lazy" width="200" height="200"

Links with more details about the feature: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/loading https://caniuse.com/loading-lazy-attr https://web.dev/browser-level-image-lazy-loading

mauriciolauffer avatar Nov 10 '20 23:11 mauriciolauffer

Hi @mauriciolauffer

The loading property exists on the HTMLImageElement class. In our project we are not instantiating any img tags, which means that we have no way to expose this property.

On the other hand, this great feature can be used by application developers who are using UI5 Web Components for their apps. For example, when they provide an img tag as a slot, they are able to set the loading attribute to lazy. For example(the ui5-carousel sample from our playground):

<ui5-carousel>
	<img src="../../../assets/images/sample1.jpg" alt="Landscape 1" loading="lazy">
	<img src="../../../assets/images/sample2.jpg" alt="Landscape 2" loading="lazy">
	<img src="../../../assets/images/sample3.jpg" alt="Bulb" loading="lazy">
</ui5-carousel>

fifoosid avatar Nov 11 '20 14:11 fifoosid

Great! Thank you for the explanation :)

mauriciolauffer avatar Nov 11 '20 20:11 mauriciolauffer