I'm working on an Angular app that displays movie/show data with a lot of images. The app structure has main Shows and nested SubItems (which only appear when clicking on a main Show). My current implementation is causing performance issues as I'm loading all images at once. Here's my data structure:
typescriptexport interface Show {
id: string;
url: string;
rating?: number;
subItems?: SubItem[];
}
interface SubItem {
id: string;
url: string;
rating: number;
prefix?: string;
}``````html
<div class="posters">
@for (show of shows; track show.url) {
<div class="poster" (click)="openDialog(show)">
<img [src]="show.url || 'https://placehold.co/400x600/EEE/31343C'" title="{{ show.id }}" alt="{{ show.id }}" class="poster__image" />
@if (show.rating) {
<div class="poster__rating">
<div class="text">{{ show.rating }}</div>
</div>
}
</div>
}
</div>
I'm using TMDB image URLs directly, like:
https://media.themoviedb.org/t/p/w440_and_h660_face/kTzJ5PrPTZVjLoKeiiShl5Z8Owf.jpg
What's the best way to optimise image loading in this scenario to improve performance?