DEV Community

Discussion on: Native lazy-loading of images with zero Javascript

Collapse
 
madsstoumann profile image
Mads Stoumann • Edited

As a sidenote, loading=“lazy” only works if JavaScript is enabled, which for me seemed a bit weird - until I read this at MDN:

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.

To test, disable JavaScript in DevTools (Shift + Command + P > Disable JavaScript), go to the Network Tab and refresh the page. All images will load instantly.

Collapse
 
pfacklam profile image
Paul Facklam

Interesting, didn't know that. Thanks for mentioning, Mads!

Collapse
 
brycewray profile image
Bryce Wray

Link where that's found:
developer.mozilla.org/en-US/docs/W...