Skip to content

Commit

Permalink
perf: make related and upsell products lazy loaded when visible
Browse files Browse the repository at this point in the history
M2-517
  • Loading branch information
bartoszherba committed May 12, 2022
1 parent 4fda801 commit e66aaec
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions packages/theme/modules/catalog/pages/product.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,12 @@
</LazyHydrate>
</div>
</div>
<LazyHydrate
when-visible
>
<LoadWhenVisible>
<RelatedProducts />
</LazyHydrate>
<LazyHydrate
when-visible
>
</LoadWhenVisible>
<LoadWhenVisible>
<UpsellProducts />
</LazyHydrate>
</LoadWhenVisible>
</div>
</SfLoader>
<LazyHydrate when-visible>
Expand Down Expand Up @@ -315,8 +311,6 @@ import { useProduct } from '~/modules/catalog/product/composables/useProduct';
import type { Product } from '~/modules/catalog/product/types';
import BundleProductSelector from '~/modules/catalog/product/components/BundleProductSelector.vue';
import GroupedProductSelector from '~/modules/catalog/product/components/GroupedProductSelector.vue';
import UpsellProducts from '~/modules/catalog/product/components/UpsellProducts.vue';
import RelatedProducts from '~/modules/catalog/product/components/RelatedProducts.vue';
import { ProductTypeUnion } from '~/modules/catalog/product/enums/ProductTypeUnion';
import InstagramFeed from '~/components/InstagramFeed.vue';
import ProductAddReviewForm from '~/components/ProductAddReviewForm.vue';
Expand All @@ -341,7 +335,8 @@ export default defineComponent({
LazyHydrate,
MobileStoreBanner: () => import('~/components/MobileStoreBanner.vue'),
ProductAddReviewForm,
RelatedProducts,
RelatedProducts: () => import('~/modules/catalog/product/components/RelatedProducts.vue'),
UpsellProducts: () => import('~/modules/catalog/product/components/UpsellProducts.vue'),
SfAddToCart,
SfBreadcrumbs,
SfButton,
Expand All @@ -356,7 +351,6 @@ export default defineComponent({
SfTabs,
AddToWishlist,
SvgImage,
UpsellProducts,
},
transition: 'fade',
setup() {
Expand Down

0 comments on commit e66aaec

Please sign in to comment.