Disabled JavaScript turns off native lazy loading (#tilPost)

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 cou…


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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » Disabled JavaScript turns off native lazy loading (#tilPost)." Stefan Judis | Sciencx - Friday September 2, 2022, https://www.scien.cx/2022/09/02/disabled-javascript-turns-off-native-lazy-loading-tilpost/
HARVARD
Stefan Judis | Sciencx Friday September 2, 2022 » Disabled JavaScript turns off native lazy loading (#tilPost)., viewed ,<https://www.scien.cx/2022/09/02/disabled-javascript-turns-off-native-lazy-loading-tilpost/>
VANCOUVER
Stefan Judis | Sciencx - » Disabled JavaScript turns off native lazy loading (#tilPost). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/09/02/disabled-javascript-turns-off-native-lazy-loading-tilpost/
CHICAGO
" » Disabled JavaScript turns off native lazy loading (#tilPost)." Stefan Judis | Sciencx - Accessed . https://www.scien.cx/2022/09/02/disabled-javascript-turns-off-native-lazy-loading-tilpost/
IEEE
" » Disabled JavaScript turns off native lazy loading (#tilPost)." Stefan Judis | Sciencx [Online]. Available: https://www.scien.cx/2022/09/02/disabled-javascript-turns-off-native-lazy-loading-tilpost/. [Accessed: ]
rf:citation
» Disabled JavaScript turns off native lazy loading (#tilPost) | Stefan Judis | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.