[Fleet] Reduce bundle sizes #82160
Labels
Team:Fleet
Team label for Observability Data Collection Fleet team
technical debt
Improvement of the software architecture and operational architecture
Goal
Aim for individual bundles under 250k uncompressed.
Why
-- Web Fundamentals docs
Reducing the uncompressed size of JS (in total & per-file) greatly reduces the work for the browser and provides a better experience for the user. There are variables like network & CPU speed but, generally, sending 1 500k bundle is worse than 2 250k or 5 100k bundles.
We're currently loading JS that's not strictly required. e.g. we load all plugin JS used anywhere when the overview page is hit. Ideally, we'd load less JS but we can at least make smaller chunks of work for the browser. Less JS might come from these changes or might happen later.
Current status
/app/ingestManager
loads ~275kb compressed or 1.8MB parsed JS in production (e.g. cloud staging)The plugin entrypoint
ingestManger.plugin.js
is about 400kWith
ingestManger.chunk.2.js
roughly half of that and an uncompressed size over 1MBWhat's in the bundles
stats.json
file vianode scripts/build_kibana_platform_plugins.js --profile --focus=ingestManager
more info*
--dist
gives is what we'll send to users, but it loses a bit of detail about the source, so I omit it while iterating on approaches* https://chrisbateman.github.io/webpack-visualizer/
* https://github.com/webpack-contrib/webpack-bundle-analyzer
How move dependencies into another bundle/chunk
TL; DR: Lazy load with
await import()
UseReact.lazy
or similar approach on client side. We should eventually have a standard way of doing this, but we don't need to come up with one before we start. More at Keep Kibana fastAnalysis & options
ingestManager.plugin.js
385kstats screenshots
esprima
(50%) andjs-yaml
(20%)kibana/x-pack/plugins/ingest_manager/common/services/full_agent_policy_to_yaml.ts
Line 6 in ad5c0f5
await fullAgentPolicyToYaml(string)
is reasonable/feasible for all consumersingestManager.chunk.2.js
(chunk.1
in dev) 1.1Mstats screenshots
d3
,react-use
,react-markdown
d3
is only used in one component. Can make this individual component lazy and/or any of the parent components which call itreact-markdown
react-use
usage docs say our this should workkibana/x-pack/plugins/ingest_manager/public/applications/ingest_manager/index.tsx
Line 8 in f5b1fae
import useObservable from 'react-use/lib/useObservable'
worked locally for mepublic/applications/sections/ingest_manager
component are in the same bundle.The text was updated successfully, but these errors were encountered: