Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: adds LazyLoadingSection component - perf (#2521)
## What's the purpose of this pull request? Adds `LazyLoadingSection` component, it will be responsible for lazy loading Sections that are out of the viewport. * It achieves this by: * 1. Using the IntersectionObserver API for Sections below the fold. * 2. Checking the UI context for Sections that are not in the viewport, such as the CartSidebar and RegionModal. We will be implementing this in the `RenderSectionsBase` as part of our upcoming tasks. This component is not being applied in isolation due to concerns about increased Cumulative Layout Shift (CLS). ## How to test it? 1. You can use this [preview link](https://starter-git-feat-lazy-loading-section-sfs-1508-faststore.vercel.app/), where the `LazyLoadingSection` is temporary applied or locally add it in `RenderSectionsBase` component. ``` <SectionBoundary key={`cms-section-${name}-${index}`} name={name}> <LazyLoadingSection sectionName={name}> <Component {...data} /> </LazyLoadingSection> </SectionBoundary> ``` 2. Inspect the code, use the React extension for this test: - search for `Footer`, you won't find it until you scroll the page until the `Newsletter` section <img width="1144" alt="image" src="https://github.com/user-attachments/assets/46e2eca0-1ce3-473c-9153-29ddb731881a"> <img width="1164" alt="image" src="https://github.com/user-attachments/assets/3132efca-38c5-4e41-b8e2-ea69b2adbf9e"> https://github.com/user-attachments/assets/bbfffbe0-39b8-4b6b-b86d-04d4a7ab1e6b ### Starters Deploy Preview vtex-sites/starter.store#586 ## References #2404 --------- Co-authored-by: Pedro Soares <[email protected]>
- Loading branch information