Skip to content

Commit b5afa3f

Browse files
nbbeekengribnoysup
andcommitted
Add documentation
Co-authored-by: Sergey Petushkov <[email protected]>
1 parent 3e20b78 commit b5afa3f

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,24 @@
11
import { 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+
*/
224
sheet.speedy(true);

packages/compass-components/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
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
14
import './force-emotion-speedy';
5+
// -------------------------------
6+
27
export * from './components/leafygreen';
38
export {
49
default as emotion,

0 commit comments

Comments
 (0)