Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: load the main product image eagerly on PDP #1717

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading