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

Feat: new RenderSections for all pages #612

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

eduardoformiga
Copy link
Member

What's the purpose of this pull request?

Applies changes from FS related PR.

Faststore related PRs

@eduardoformiga eduardoformiga requested a review from a team as a code owner November 12, 2024 22:32
Copy link

vercel bot commented Nov 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
starter ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 26, 2024 8:58pm

eduardoformiga added a commit to vtex/faststore that referenced this pull request Dec 3, 2024
Depends on 
- #2555

## What's the purpose of this pull request?

This PR is part of the performance initiative. 

It aims to create a new structure for the `RenderSections` that uses the
`ViewportObserver` along with the `LazyLoadingSection` to load the
section on demand. Now, the RenderSections receives the `globalSection`
as props, and we are removing the `GlobalSection` (parent) Component
that wraps the pages.

It also applies this structure to all pages:
- home
- pdp
- plp
- login
- checkout
- account
- search
- landing page
- 500
- 404


PS: some changes from PLP and Landing Page need to be applied now. Then
I applied some `Promise.all` and other improvements beforehand.

## How to test it?

Now, we can only load the JS for the sections inside the viewport during
the first load. You can check the network tab in devtools while
scrolling the page until the `Footer` to double-check the JS for
sections above the fold being loaded.

You can run the project locally or use the starter preview to
double-check this behavior.

you can test all the pages. The landing page can be accessed through
this URL:
http://localhost:3000/my-landing-page



https://github.com/user-attachments/assets/8d69faa5-782f-4fb4-81fc-fd637043870b

## Performance

||Before|After|
|-|-|-|

||https://starter.vtex.app/|https://sfj-b662675--starter.preview.vtex.app/|
|on a lucky day (when PSI has a good sense of humor, haha)|<img
width="791" alt="Screenshot 2024-11-12 at 19 49 50"
src="https://github.com/user-attachments/assets/c1392da6-2e82-40ac-85dd-3367e607752f">|<img
width="795" alt="Screenshot 2024-11-12 at 19 50 00"
src="https://github.com/user-attachments/assets/e05ab731-5e20-4f2e-b304-97d63efd9d84">|
|on a normal day|<img width="804" alt="Screenshot 2024-11-12 at 19 54
24"
src="https://github.com/user-attachments/assets/9706709a-00ee-40a2-ae2b-8d5678489b9e">|<img
width="789" alt="Screenshot 2024-11-12 at 19 54 17"
src="https://github.com/user-attachments/assets/e4947d10-9dfc-491c-9165-a1725e935e11">|

### Starters Deploy Preview

- vtex-sites/starter.store#612

preview 
https://sfj-b662675--starter.preview.vtex.app/

## References

In this video, you can see an explanation of loading JS on demand using
the Intersection Observer API + code splitting.

https://drive.google.com/file/u/1/d/13VYPu45Vaav2ecGmKcFAOUMKAS3pMHd4/view

POC PR
- #2404
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant