-
Notifications
You must be signed in to change notification settings - Fork 142
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
Optimize Server-side performance #667
Conversation
packages/template-retail-react-app/app/components/link/index.jsx
Outdated
Show resolved
Hide resolved
packages/template-retail-react-app/app/hooks/use-url-template.js
Outdated
Show resolved
Hide resolved
packages/template-retail-react-app/app/hooks/use-url-template.js
Outdated
Show resolved
Hide resolved
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.
Let me skim the rest of the changes. I'm not too familiar with other changes that were requested. But I may still give a +1 if things look all right to me.
packages/template-retail-react-app/app/hooks/use-url-template.js
Outdated
Show resolved
Hide resolved
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.
Besides one comment about locale
in AppConfig, everything else looks good to me 👍
Description
First iteration improving Retail React App Server-side performance.
Problem
Analyzing the Chrome DevTools CPU Profiler results we see today we run a quite expensive method
buildPathWithUrlConfig()
every time we need to build a URL, which includes running the method on every Link rendered by the App.Solution
The pattern we use to build URLs doesn't change in the App unless we change the App default configuration values or unless we do a hard refresh (e.g. Choosing a different locale using the locale selector in the Footer).
The proposed solution is to use React.Context to provide the URL template literal with the pattern to build URLs to the entire App.
createUrlTemplate()
function generating the URL template literal is executed only once.buildPathWithUrlConfig()
method is replaced and re-implemented by thecreateUrlTemplate()
method. Removing and unrolling loops with a set of conditionals to reflect the potential URL configurations.Results
Home Page Sever-side
Product List Page Sever-side
Types of Changes
Changes
<MultiSiteProvider />
to AppConfig to provide the multi-site related values to the entire App:locale
,site
andbuildUrl()
function that returns a URL template literal with the pattern to build URLs according to the App configuration defined indefault.js
file.How to Test-Drive This PR
Using Chrome DevTools:
Checklists
General
Accessibility Compliance
You must check off all items in one of the follow two lists:
or...
Localization