# \[loading\]

> The `loading` HTML attribute indicates whether an image or iframe should be loaded immediately or lazily.

## How do I lazy load images with the loading attribute?

The attribute of `<img>` and `<iframe>` elements that controls when the resource is loaded. The 'lazy' value defers loading until the element approaches the viewport, reducing initial page weight, while 'eager' loads it immediately.

- Topic: Element Attributes
- Type: attribute
- Browser support: Chrome 77+, Chrome Android 77+, Edge 79+, Firefox 75+, Firefox Android 79+, Safari 15.4+, Safari iOS 15.4+

## Example

Wrong:

```html
<img src="hero.jpg" alt="Team at work"
  loading="lazy">
```

Right:

```html
<img src="hero.jpg" alt="Team at work" width="1200" height="600">
<img src="chart.png" alt="Sales chart" width="800" height="400" loading="lazy">
```

The hero loads at once, and only the image further down the page is lazy loaded.

## Common mistakes

- Putting `loading='lazy'` on the hero image, which delays the largest paint.

## Key points

- Images above the fold, including the LCP image, are not marked `loading='lazy'`.
- Lazy images have `width` and `height` so the layout does not jump when they load.
- Native `loading='lazy'` is used instead of a JS lazy loading library with `data-src`.

## Interview questions

### What values does the loading attribute accept?

'eager', the default, loads at once. 'lazy' delays loading until the element is near the viewport.

### Does loading='lazy' work on iframes?

Yes. It works on `<img>` and `<iframe>` elements.

### Do I still need IntersectionObserver for lazy images?

Not for plain lazy loading. Use it only for custom behavior the attribute cannot do.

## Related cards

- [\[fetchpriority\]](https://wonderium.dev/html/fetchpriority.md)
- [`<img>`](https://wonderium.dev/html/img.md)
- [`<iframe>`](https://wonderium.dev/html/iframe.md)
- [LCP](https://wonderium.dev/web/lcp.md)
- [CLS](https://wonderium.dev/web/cls.md)

---

- Level: [HTML](https://wonderium.dev/html.md)
- HTML version: https://wonderium.dev/html/loading-attribute
- Last updated: 2026-11-25
