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

Optimize JS bundle and try to reduce its size #446

Open
ishubin opened this issue Aug 18, 2021 · 5 comments
Open

Optimize JS bundle and try to reduce its size #446

ishubin opened this issue Aug 18, 2021 · 5 comments

Comments

@ishubin
Copy link
Owner

ishubin commented Aug 18, 2021

No description provided.

@ishubin ishubin added the P-1 Highest importance label Aug 18, 2021
@ishubin ishubin removed the P-1 Highest importance label Oct 24, 2022
@eugef
Copy link

eugef commented Oct 25, 2022

Hi @ishubin, if this issue is still relevant, I can take a look into it.

@ishubin
Copy link
Owner Author

ishubin commented Oct 25, 2022

Hey @eugef , that would be great! Honestly I don't remember all the details and I am not even sure what the acceptable client-side js bundle size is for such kind of application. I did look into this issue about a year ago and I remember that the largest library was a css processor. . Next largest one I think was lodash. I already did some optimizations to lodash by switching from global import (import _ from "lodash") to importing only the used functions (e.g. import from "lodash/forEach").

Right now the complete production bundle for Schemio is around 1.6 MB and for standalone player (without editor) - 588K. So, again, I don't know what the acceptable bundle size is for such an application. What do you think?

@eugef
Copy link

eugef commented Nov 11, 2022

Hi @ishubin I have quickly analysed the schemio.app.drive.js bundle using webpack-bundle-analyzer tool.

The only obvious problem I've notices is indeed usage of monolithic lodash.js instead of specific lodash functions.
I think removing all import _ from "lodash" should help to reduce the bundle size by ~400-500 kb

Screenshot 2022-11-11 at 16 06 48

@eugef
Copy link

eugef commented Nov 11, 2022

I have also analysed the schemio-standalone.js bundle and it has another potential problem.

As you can see the bundle contains postcss/lib code. AFAIK postcss should only be used during the build process, so it is very strange to see its code in a runtime bundle.

Screenshot 2022-11-11 at 16 20 04

@ishubin
Copy link
Owner Author

ishubin commented Nov 11, 2022

Thanks for the check @eugef , I thought I got rid of global lodash import. I guess I was wrong.
As for postcss I also don't understand how it gets in there. Will take a look into once I am done with electron branch.
Thanks a lot for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants