Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use native lazy loading for fallback images #20

Open
makkabi opened this issue Jul 27, 2020 · 0 comments
Open

Use native lazy loading for fallback images #20

makkabi opened this issue Jul 27, 2020 · 0 comments

Comments

@makkabi
Copy link

makkabi commented Jul 27, 2020

Right now, if you use the interactive embed and the user has JS activated, the fallback image will still be loaded, despite never beeing shown. This can be easily avoided by adding loading="lazy" to the img-Element. Most browsers support it already, and those wo don't just ignore the attribute:
https://caniuse.com/#feat=loading-lazy-attr

I tested this in Firefox and Chromium-Edge, and it works fine. As far as I understand the native lazy-loading attribute can be added without risk or downsides, and we could save time, money, CO2 etc.

Example:

<p class="ciu_embed" data-feature="dialog" data-periods="future_1,current,past_1,past_2" data-accessible-colours="false">
		<picture>
			<source type="image/webp" srcset="https://caniuse.bitsofco.de/image/dialog.webp">
			<source type="image/png" srcset="https://caniuse.bitsofco.de/image/dialog.png">
			<img loading="lazy" src="https://caniuse.bitsofco.de/image/dialog.jpg" alt="Data on support for the dialog feature across the major browsers from caniuse.com">
		</picture>
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant