Artboard 16light, inspiration, solution, idea, innovation,Google Sheets iconSwift icon
Published at
Updated at
Reading time
1min
This post is part of my Today I learned series in which I share all my web development learnings.

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.

Related Topics

Related Articles