Skip to content

Commit

Permalink
perf: load the main product image eagerly on PDP (#1717)
Browse files Browse the repository at this point in the history
* because it is the LCP on this page
* first product image on product image slider
  • Loading branch information
SGrueber authored Dec 20, 2024
1 parent 16b6afa commit 9326b29
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
[ngClass]="{ 'product-image-zoom': zoomImageIds$ | async }"
imageType="L"
[imageView]="imageView"
[loading]="i === 0 ? 'eager' : 'lazy'"
/>
</div>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ng-container *ngIf="productImage$ | async as image; else noImage">
<img
*ngIf="image.effectiveUrl; else noImage"
loading="lazy"
[attr.loading]="loading"
class="product-image"
[src]="image.effectiveUrl"
[attr.height]="image.imageActualHeight"
Expand All @@ -25,7 +25,7 @@

<ng-template #noImage>
<img
loading="lazy"
[attr.loading]="loading"
class="product-image"
src="/assets/img/not-available.svg"
[attr.alt]="'product.image.not_available.alttext' | translate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export class ProductImageComponent implements OnInit {
* A custom alt text for the img tag.
*/
@Input() altText: string;
/**
* The image loading strategy.
*/
@Input() loading: 'lazy' | 'eager' | 'auto' = 'lazy';

productURL$: Observable<string>;
productImage$: Observable<Image>;
Expand Down

0 comments on commit 9326b29

Please sign in to comment.