-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Lazy loading React components #64179
Comments
Pinging @elastic/kibana-platform (Team:Platform) |
Pinging @elastic/kibana-gis (Team:Geo) |
We have the same problem for
|
Pinging @elastic/kibana-operations (Team:Operations) |
Wonder if React.lazy and Suspense are working in Kibana env? If yes, I guess we won't need |
@Dosant yes. I did try it in our app and all integration tests passed.
I think you can use |
@restrry, thanks for checking react.lazy 👍 |
Related to #58280 |
@restrry, @elastic/kibana-app-arch is going to look into generic approach for code splitting of app arch registries and components during our next planning week. |
I created this issue to discuss the lazy loading strategy for react components used by different registries in Kibana.
If you build Kibana platform plugins locally and check their sizes. You can notice that
maps
plugin size reaches 4.8Mb.That's mostly due to new
optimizer
architecture including all the plugin dependencies in the bundle and lack of code tree-shaking (WIP #62390). Even if we move some deps to shared dependencies and remove unused code, the build size will be quite significant (@elastic/ems-client, @elastic/maki only gives us 1Mb)Ideally, a plugin code should be as slim as possible and include the thing that necessary for proper registration. All other code must be loaded on demand.
I'm wondering if we can improve the situation with loading Maps React components on demand.
To understand how it affects the initial load time let's look at
maps.plugin.js
size (this is the chunk loaded every time a user opens the Kibana):without lazy loading - 4.8Mb
with
MapViewComponent
loaded lazily - 29KbThere are several approaches to address the problem:
Maybe @elastic/kibana-app-arch has other ideas or opinion of whatever pattern is preferable?
The text was updated successfully, but these errors were encountered: