-
Notifications
You must be signed in to change notification settings - Fork 239
fix(components): always force speedy mode for emotion to avoid performance issues in dev mode COMPASS-9828 #7305
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
755cf5a
fix(components): always force speedy mode for emotion to avoid perfor…
gribnoysup 3e20b78
chore: improve exiting of sync script
nbbeeken b5afa3f
Add documentation
nbbeeken dcd7e3f
Update packages/compass-components/src/force-emotion-speedy.ts
nbbeeken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { sheet } from '@leafygreen-ui/emotion'; | ||
| /** | ||
| * Emotion will dynamically decide which style insertion method to use based on | ||
| * the "env" it is built for: in "development" mode it uses a method of | ||
| * inserting literal style tags with css as text inside of them for every `css` | ||
| * method call to apply styles to the page. This method is really slow, every | ||
| * single style tag insertion causes style recalculation that can end up | ||
| * blocking the main thread for multiple seconds, when accumulated this can | ||
| * result in minutes of unresponsive page behavior. In "production" mode the | ||
| * style insertion is done using a modern JS API that doesn't result in such | ||
| * drastic performance issues. | ||
| * | ||
| * Specifically when embedding compass-web in mms, there is a massive | ||
| * performance hit that can be observed when emotion is not running in "speedy" | ||
| * mode, so to work around that we are always forcing emotion to enable it. | ||
| * | ||
| * Historically "speedy" mode was only active in production because editing | ||
| * styles in the browser devtools didn't work otherwise, nowadays there is no | ||
| * reason to not use it always, so there should be no downsides to doing this. | ||
| * | ||
| * See also https://github.com/10gen/compass-data-explorer/pull/11 where we | ||
| * already ran into a similar issue. | ||
| */ | ||
| sheet.speedy(true); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.