DEV Community

Farai Gandiya
Farai Gandiya

Posted on • Originally published at codelab.farai.xyz on

The img loading Attribute Won’t Lazy Load Unless JavaScript is Enabled

The img loading Attribute Won’t Lazy Load Unless JavaScript is Enabled was originally published on Farai's Codelab.


The loading attribute let’s you control how images and iframes are loaded. Turns out this will only work is JavaScript is enabled.

From the WHATWG HTML loading attribute spec:

If scripting is disabled for element, then return false…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.

Rather inconvenient but it’s not the end of the world. People are used to evey image loading whether you scroll to it or not so losing this feature may be worth intentionally disabling JavaScript given all the ways JavaScript can target you.


Thanks for reading. If you liked this post, support my work by sharing this post, refering me for a job, sponsoring me on Patreon, sending me money on Ko-fi, Paypal or Buy Me A Coffee. You could also use my affiliate links to buy something on Amazon or Namecheap. Note that I may earn a commisions through those links.

Got feedback? Email me at gandiyafarai + feedback at gmail dot com.

Latest comments (0)