-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
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
[docs] Fix leaking lazy stylesheets #20903
Conversation
Details of bundle changes.Comparing: f7e6cb6...4e3c142 Details of page changes
|
styleNode.parentElement.removeChild(styleNode); | ||
}; | ||
}, []); | ||
useLazyCSS('https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css', '#app-search'); |
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.
If we take the case of a page transition between /components/speed-dial/
-> /components/rating/
we remove the CSS of Algolia to append them back a few ms later (it doesn't happen for the other assets). We could wonder:
Should we be worried about removing and appending CSS a few ms later?
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.
Should we be worried about removing and appending CSS a few ms later?
What are you worried about?
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.
It's more my curiosity speaking than any of my fears. I'm curious to better understand how the CSS engine performs.
I imagine the concern is close to: What's wrong with leaking a few CSS files? I assume it boils down to improving the performance of the page. I don't have enough knowledge of how the CSS engine performs to tell. I thought that it was interesting to raise the side effect with the Algolia search for a page transition.
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.
What's wrong with leaking a few CSS files?
We're not leaking anything here. We're actually leaking less. The docsearch css is reloaded on master as well.
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 just realized: This change didn't even change anything for algolia. Any behavior you see related to docsearch.min.css happens on master as well.
For the prism css it's more of a precaution in case we ever unmount it.
We didn't consistently clean up the create
<link />
elements. Fixed it in the demos and created a separate hook that prevents incorrect usage.