Skip to content

perf(cdk/overlay): add tree-shakeable alternatives for overlay APIs #30904

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

Merged
merged 1 commit into from
Apr 20, 2025

Conversation

crisbeto
Copy link
Member

Currently all the overlay APIs go through the Overlay service which means that even if an app only uses the fairly simple global positioning strategy, they'd still bring in all the code for the complex flexible positioning strategy.

These changes break up the APIs into constructor functions that can be tree shaken separately.

Note that I'll send follow-up PRs to roll this out in Material in order to see the full benefits.

From a simple test of a an ng new app that only uses MatTooltip, this shaved off ~10kb of minified JS.

@crisbeto crisbeto added the target: major This PR is targeted for the next major release label Apr 19, 2025
@crisbeto crisbeto requested a review from a team as a code owner April 19, 2025 09:42
@crisbeto crisbeto requested review from adolgachev and andrewseguin and removed request for a team April 19, 2025 09:42
@angular-robot angular-robot bot added area: performance Issues related to performance area: cdk/overlay labels Apr 19, 2025
Currently all the overlay APIs go through the `Overlay` service which means that even if an app only uses the fairly simple global positioning strategy, they'd still bring in all the code for the complex flexible positioning strategy.

These changes break up the APIs into constructor functions that can be tree shaken separately.

Note that I'll send follow-up PRs to roll this out in Material in order to see the full benefits.

From a simple test of a an `ng new` app that only uses `MatTooltip`, this shaved off ~10kb of minified JS.
@crisbeto crisbeto force-pushed the overlay-tree-shake branch from ea6230e to fb56acd Compare April 19, 2025 16:59
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Apr 20, 2025
@crisbeto crisbeto removed the request for review from adolgachev April 20, 2025 16:44
@crisbeto crisbeto merged commit 08f4acf into angular:main Apr 20, 2025
21 of 24 checks passed
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: cdk/overlay area: performance Issues related to performance target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants