-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
perf(v2): load algolia JS only when user interacts with search #2076
Conversation
Deploy preview for docusaurus-2 ready! Built with commit 998fc89 |
Deploy preview for docusaurus-preview ready! Built with commit 998fc89 |
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.
Very nice! Refer to comments :smile
packages/docusaurus-theme-search-algolia/src/theme/SearchBar/index.js
Outdated
Show resolved
Hide resolved
}); | ||
const loadAlgoliaJS = () => { | ||
if (!loadedJs) { | ||
loadJS().then(a => { |
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.
Wanna add some error handling?
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.
I dont know what kind of error should be introduced. Previously doesnt have it too.
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.
LGTM
Motivation
Docsearch bundle size is a whooping 35kbs gzipped. That's huge ...
Trying to improve our TTI performance by only loading algolia when user interact with the search
Have you read the Contributing Guidelines on pull requests?
yes
Test Plan
Still working ✌️
Notice how the bundle is only loaded when user interact with it
Benefit.
This increase our lighthouse TTI by 1s
After is 2.8s+
Before was 3.9s +
Slight caveat: