This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis
It's speedy TIL time! Did you know the loading="lazy"
attribute doesn't work when you turn off JavaScript?
Now, you do. 😉
Why doesn't lazy load work without JS? There's only one reason why we can't have nice things: of course, it's for tracking prevention.
Here's the loading
MDN documentation explaining the behavior:
Loading is only deferred when JavaScript is enabled. This is an anti-tracking measure, because if a user agent supported lazy loading when scripting is disabled, it would still be possible for a site to track a user's approximate scroll position throughout a session, by strategically placing images in a page's markup such that a server can track how many images are requested and when.
And if you really want to get into this topic, here's the related spec describing when loading="lazy"
should work.
And just to be clear, because some folks were confused: images will still load when JS is disabled. It's only the deferred loading that won't work.
Reply to Stefan
This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis

Stefan Judis | Sciencx (2022-09-02T22:00:00+00:00) Disabled JavaScript turns off native lazy loading (#tilPost). Retrieved from https://www.scien.cx/2022/09/02/disabled-javascript-turns-off-native-lazy-loading-tilpost/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.