---
title: "How do you lazy load images in Angular and Ionic?"
description: "Lazy load images with the native loading=lazy attribute, Ionic's ion-img component or Angular's NgOptimizedImage so off-screen images load only when needed."
url: "https://bugsee.com/answers/ionic/angular-lazy-load-images/"
---

# How do you lazy load images in Angular and Ionic?

Add `loading="lazy"` to the `<img>` tag, or use Ionic's `<ion-img>`, which loads the image only when it scrolls into view.

```html
<!-- Native browser lazy loading -->
<img src="assets/photo.jpg" loading="lazy" width="320" height="240" alt="Photo" />

<!-- Ionic component: loads when it enters the viewport -->
<ion-img src="assets/photo.jpg" alt="Photo"></ion-img>

<!-- Angular's optimized image directive: lazy by default, set priority for the hero image -->
<img ngSrc="assets/photo.jpg" width="320" height="240" alt="Photo" />
```

- Always set `width` and `height` (or use CSS aspect-ratio) so the layout does not jump when the image appears.
- Do not lazy load images that are visible on first paint; it delays them.
- Inside `ion-content` lists, `ion-img` works well because it observes the scrolling container.
- For custom behavior, an IntersectionObserver in a small directive can set `src` when the element becomes visible.

## Related questions

- [How do you add infinite scroll to an Ionic list?](https://bugsee.com/answers/ionic/ionic-infinite-scroll/)
