πŸŽ‰ We just launched our new React course! Get it with 20% off! πŸŽ‰
How to Lazy Load Images Natively in HTML

How to Lazy Load Images Natively in HTML

Ferenc Almasi β€’ 2020 September 28 β€’ πŸ“– 1 min read
  • twitter
  • facebook

Simply use loading=”lazy” in img tags to lazy load them.

<!-- Use the loading attribute on images to defer the loading of offscreen images -->
<img src="lazy-loading.jpg" loading="lazy" />
loading.html
Copied to clipboard!

Please note that this feature is not widely supported, which means you need to provide fallback solutions. For the full list of supported browsers, check out the support table on caniuse.com.

If your browser does not support the loading attribute, it will simply ignore it, so you don't have to worry about introducing bugs.

How to Lazy Load Images Natively in HTML
If you would like to see more Webtips, follow @flowforfrank

How to Lazy Load Images Natively
Looking to improve your skills? Check out our interactive course to master JavaScript from start to finish.
Master JavaScript

Resources:

JavaScript Course Dashboard

Tired of looking for tutorials?

You are not alone. Webtips has more than 400 tutorials which would take roughly 75 hours to read.

Check out our interactive course to master JavaScript in less time.

Learn More

Recommended