[Discover] Optimize Discover plugin page load bundle (#208298)

## Summary

This PR optimizes the Discover page load bundle by reducing it to only
code which is actually required on startup, and dynamically loading
other code when it's needed, resulting in a 55% decrease in the bundle
size.

Before (44.15 KB):

![before](https://github.com/user-attachments/assets/989d1626-4dd7-4710-a9bc-8d80220101eb)

After (20.12 KB):

![after](https://github.com/user-attachments/assets/ff68b367-3293-47cf-9d3f-5c35d0aea27a)

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Davis McPhee 2025-03-11 17:30:25 -03:00 committed by GitHub
parent 99d8400328
commit e1bffa6a9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
47 changed files with 991 additions and 739 deletions

View file

@ -34,7 +34,7 @@ pageLoadAssetSize:
dataViews: 65000
dataVisualizer: 30000
devTools: 38637
discover: 99999
discover: 25000
discoverEnhanced: 42730
discoverShared: 17111
embeddable: 24000