File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
packages/compass-components/src Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 11import { sheet } from '@leafygreen-ui/emotion' ;
2+ /**
3+ * Emotion will dynamically decide which style insertion method to use based on
4+ * the "env" it is built for: in "development" mode it uses a method of
5+ * inserting literal style tags with css as text inside of them for every `css`
6+ * method call to apply styles to the page. This method is really slow, every
7+ * single style tag insertion causes style recalculation that can end up
8+ * blocking the main thread for multiple seconds, when accumulated this can
9+ * result in minutes of unresponsive page behavior. In "production" mode the
10+ * style insertion is done using a modern JS API that doesn't result in such
11+ * drastic performance issues.
12+ *
13+ * Specifically when embedding compass-web in mms, there is a massive
14+ * performance hit that can be observed when emotion is not running in "speedy"
15+ * mode, so to work around that we are always forcing emotion to enable it.
16+ *
17+ * Historically "speedy" mode was only active in production because editing
18+ * styles in the browser devtools didn't work otherwise, nowadays there is no
19+ * reason to not use it always, so there should be no downsides to doing this.
20+ *
21+ * See also https://github.com/10gen/compass-data-explorer/pull/11 where we
22+ * already ran into a similar issue.
23+ */
224sheet . speedy ( true ) ;
Original file line number Diff line number Diff line change 1+ // IMPORTANT: this import should always be the first one in compass-component
2+ // main entrypoint to ensure that emotion is reconfigured before any component
3+ // modules generate their stylesheets
14import './force-emotion-speedy' ;
5+ // -------------------------------
6+
27export * from './components/leafygreen' ;
38export {
49 default as emotion ,
You can’t perform that action at this time.
0 commit comments