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

[Modal] -74% bundle size reduction when used standalone #15466

Merged
merged 1 commit into from
Apr 25, 2019

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Apr 23, 2019

I wanted to try this change for months! #5750 gave me enough energy to start. The core idea behind this change is that we document the Modal component as a good starting point to build a Modal (outside of Material Design). This vision can only be achieved with an outstanding small bundle size.

This change doesn't help people already using @material-ui/styles and our theme. But it reduces the entry cost for new developers. A developer can progressively add our generic components, with only paying for what he needs.

Modal | -74.06% | -72.43% | 79,337 | 20,578 | 23,972 | 6,609

From 23.4 kB gzipped to 6.5 kB gzipped. We can still do better. The react hooks migration will help. We should be able to go down to 5.5 kB.

Breaking change

Remove the classes customization API for the Modal component.

@oliviertassinari oliviertassinari changed the title [Modal] +250% bundle size reduction [Modal] -250% bundle size reduction Apr 23, 2019
@mui-pr-bot
Copy link

mui-pr-bot commented Apr 23, 2019

@material-ui/core: parsed: 0.00% 😍, gzip: +0.17%

Details of bundle changes.

Comparing: 387b79e...fa21113

bundle parsed diff gzip diff prev parsed current parsed prev gzip current gzip
@material-ui/core 0.00% +0.17% 🔺 311,042 311,048 84,214 84,353
@material-ui/core/Paper 0.00% +0.05% 🔺 67,279 67,279 19,970 19,980
@material-ui/core/Paper.esm +0.07% 🔺 -0.03% 60,640 60,685 18,897 18,892
@material-ui/core/Popper -0.01% +0.07% 🔺 31,115 31,113 10,793 10,801
@material-ui/core/Textarea 0.00% -0.04% 5,472 5,472 2,367 2,366
@material-ui/core/TrapFocus 0.00% -0.06% 3,731 3,731 1,565 1,564
@material-ui/core/styles/createMuiTheme +0.28% 🔺 +0.14% 🔺 15,898 15,943 5,770 5,778
@material-ui/core/useMediaQuery 0.00% +0.10% 🔺 2,106 2,106 973 974
@material-ui/lab +0.03% 🔺 -0.19% 140,720 140,760 42,642 42,560
@material-ui/styles 0.00% +0.03% 🔺 50,833 50,835 15,019 15,023
@material-ui/system 0.00% +0.03% 🔺 11,765 11,765 3,922 3,923
Button +0.05% 🔺 +0.09% 🔺 85,622 85,663 25,618 25,640
Modal -74.06% -72.43% 79,337 20,578 23,972 6,609
colorManipulator 0.00% 0.00% 3,904 3,904 1,543 1,543
docs.landing 0.00% 0.00% 51,154 51,154 11,250 11,250
docs.main +0.11% 🔺 +0.06% 🔺 648,059 648,749 202,187 202,317
packages/material-ui/build/umd/material-ui.production.min.js +0.16% 🔺 +0.13% 🔺 292,088 292,546 82,119 82,227

Generated by 🚫 dangerJS against fa21113

@oliviertassinari oliviertassinari changed the title [Modal] -250% bundle size reduction [Modal] -74% bundle size reduction Apr 23, 2019
@oliviertassinari oliviertassinari added component: modal This is the name of the generic UI component, not the React module! performance labels Apr 23, 2019
@oliviertassinari oliviertassinari marked this pull request as ready for review April 23, 2019 20:54
@oliviertassinari oliviertassinari merged commit 2a87578 into mui:next Apr 25, 2019
@oliviertassinari oliviertassinari deleted the smaller-modal branch April 25, 2019 07:03
@oliviertassinari oliviertassinari changed the title [Modal] -74% bundle size reduction [Modal] -74% bundle size reduction when used standalone Apr 28, 2019
@eluchsinger
Copy link
Contributor

eluchsinger commented Apr 29, 2019

@oliviertassinari just a question: Why did the bundle grow (gzip: +0.17%), if the Modal shrank?

@oliviertassinari
Copy link
Member Author

This change doesn't help people already using @material-ui/styles and our theme. But it reduces the entry cost for new developers. A developer can progressively add our generic components, with only paying for what he needs.

@eluchsinger It's because of a simplified default backdrop.

@oliviertassinari
Copy link
Member Author

oliviertassinari commented Apr 29, 2019

Also, we shouldn't look at the gzipped diff that much. It dependents on the heuristic the compressions the algorithm uses. The parsed one is often more "stable" (more stability to code changes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: modal This is the name of the generic UI component, not the React module! performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants