-
Notifications
You must be signed in to change notification settings - Fork 398
CHECKOUT-9513: Hydrate initial state to reduce latency caused by request waterfalls #2422
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
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
8cef4fe
to
4fa5c57
Compare
55cf71b
to
9c8e772
Compare
8223d30
to
6639157
Compare
6d17003
to
9320729
Compare
e49c742
to
95ad839
Compare
2963db3
to
993511f
Compare
throw error; | ||
}); | ||
} else { | ||
requestAnimationFrame(async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why we need to wrap the initial render and hydration calls in requestAnimationFrame
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is to spread the work across multiple tasks so we don't do too much in a single one, as this could negatively impact Total Blocking Time. Having said that, I notice I'm using two, so I'll look into whether I need both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I checked. We do need do break up the task in both places. But I found that requestAnimationFrame
is not the most ideal. scheduler.yield
(https://developer.mozilla.org/en-US/docs/Web/API/Scheduler/yield) is a better option.
993511f
to
47cbb5a
Compare
checkout-js deployed to Integration US |
checkout-js deployed to Staging US |
⚡️ Lighthouse results🖥️ Desktop:
📱 Mobile:
|
What/Why?
This PR leverages the Checkout SDK’s new capability to hydrate CheckoutService with initial state from the server. This eliminates client-side API calls on page load, resulting in faster performance and an improved user experience.
See bigcommerce/checkout-sdk-js#2934
Rollout/Rollback
Revert or turn off
CHECKOUT-9388.initial_state_for_checkout_app
experimentTesting
CircleCI