elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.68k stars 8.23k forks source link

Reduce `core` bundle size #95890

Open mshustov opened 3 years ago

mshustov commented 3 years ago

Parent issue https://github.com/elastic/kibana/issues/95853

Core bundle size is critical for performance because it's loaded on every page and delays all other plugin initialization affecting perceived UI performance.

There are still lots of options to improve Core bundle size, just a few ideas:

We don't aim to abide by the 100KB limit set for plugins. The limit bundle size value for Core should be investigated as a part of this issue.

elasticmachine commented 3 years ago

Pinging @elastic/kibana-core (Team:Core)

pgayvallet commented 3 years ago

Not sure we can gain much with async loading UI components in core, as we are just delegating to EUI which is already a shared dep.

E.g

The banners service is already lazy loading react-markdown

https://github.com/elastic/kibana/blob/4584a8b570402aa07832cf3e5b520e5d2cfa7166/src/core/public/overlays/banners/user_banner_service.tsx#L27

The rest of the UI component in UserBannerService is mostly using EUI. Async loading that would be a gain of less than 1kb.

Only UI component here is

https://github.com/elastic/kibana/blob/4584a8b570402aa07832cf3e5b520e5d2cfa7166/src/core/public/overlays/flyout/flyout_service.tsx#L121-L128

As @elastic/eui is already a shared dep, we wouldn't gain anything here

Same, UI comp is only a passthough to EUI

https://github.com/elastic/kibana/blob/8126488021b2efd674ea1ddec3c99c24029879f5/src/core/public/overlays/modal/modal_service.tsx#L199-L204

The toast list is currently rendered during startup

https://github.com/elastic/kibana/blob/4584a8b570402aa07832cf3e5b520e5d2cfa7166/src/core/public/notifications/toasts/toasts_service.tsx#L49-L61

Changing to lazy load would force us to adapt the code to only render the component when a first toast is actually received.

Also GlobalToastList is a very thin wrapper around EUI's EuiGlobalToastList, and as @elastic/eui is already in the shared deps, the gain would only be of a few bytes.

So I don't think we should do anything for overlays/banners

Opened a PR https://github.com/elastic/kibana/pull/96020 to try that one. I guess the gain will be negligible too, but waiting for CI.