Skip to content
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

[8.x] [Discover] Optimize Discover plugin page load bundle (#208298) #214867

Merged
merged 1 commit into from
Mar 18, 2025

Conversation

davismcphee
Copy link
Contributor

Backport

This will backport the following commits from main to 8.x:

Questions ?

Please refer to the Backport tool documentation

## 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>
(cherry picked from commit e1bffa6)

# Conflicts:
#	src/platform/plugins/shared/discover/public/__mocks__/services.ts
#	src/platform/plugins/shared/discover/public/index.ts
#	src/platform/plugins/shared/discover/public/plugin.tsx
#	src/platform/plugins/shared/discover/public/types.ts
@davismcphee davismcphee enabled auto-merge (squash) March 17, 2025 19:16
@davismcphee davismcphee self-assigned this Mar 17, 2025
@davismcphee davismcphee added the Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. label Mar 17, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
discover 1239 1248 +9

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
discover 106 95 -11

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
discover 965.3KB 1003.5KB +38.2KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
discover 24 22 -2

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
discover 45.9KB 21.9KB -24.0KB
Unknown metric groups

API count

id before after diff
discover 155 144 -11

async chunk count

id before after diff
discover 32 33 +1

References to deprecated APIs

id before after diff
discover 12 11 -1
logsExplorer 0 1 +1
securitySolution 469 470 +1
total +1

cc @davismcphee

@davismcphee davismcphee merged commit 6d2411f into elastic:8.x Mar 18, 2025
14 checks passed
@davismcphee davismcphee deleted the backport/8.x/pr-208298 branch March 18, 2025 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants