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

Excessive Bundle Size #1024

Open
ppeg34 opened this issue Nov 27, 2020 · 3 comments
Open

Excessive Bundle Size #1024

ppeg34 opened this issue Nov 27, 2020 · 3 comments

Comments

@ppeg34
Copy link

ppeg34 commented Nov 27, 2020

The checkout sdk accounts for a very significant portion of our bundle size...
Screen Shot 2020-11-27 at 12 30 08 PM

In addition to the ~500k size in the attached screenshot, it brings in rxjs to tack on another 100k dependency. For starters removing this (also from @bigcommerce/data-store) could significantly help.

All-in-all this accounts for the majority of our app bundle size for our checkout process.

@ankurbigcomm
Copy link
Contributor

Thank you for the suggestion @ppeg34 . Happy to take it up with the team and see what can be done to reduce the bundle size.

@davidchin
Copy link
Contributor

Hi @ppeg34, we won't be able to replace the aforementioned dependencies without a significant rewrite. And the replacement wouldn't guarantee a significant reduction in size, considering we need to retain existing functionality.

What we can do, however, is to see if we can optimise code splitting and tree shaking, so that we can eliminate code from the bundle that's not in use by its consumer. We do have a long standing ticket CHECKOUT-3009 tracking this issue. Hopefully we can make some progress in the near future.

PS: One thing to note is that we should look at the gzip size instead of the raw size. So in your case, it's ~100kb instead of ~500kb. Having said that, it's still high, so there's still room for improvement.

@tleunen
Copy link

tleunen commented Jan 18, 2022

Hi @davidchin ,

That is great you have an internal ticket to follow up on this issue. As you said, 100kb gzip is also too high for a library. Outside of trying to remove some of your dependencies like RxJS which would require quite a rewrite from you, I'd encourage to revisit the way you build the library and deliver that to the consumers.

Currently, you create multiple bundles (checkout-sdk, embedded-checkout, checkout-button, ..). I believe that's where the huge gain could come. Instead of creating bundles and giving bundles to consumers, simply convert the code to ES5 (or anything you want) without creating any bundles. That way, code splitting can be done on the consumer side properly. I'd guess that most people don't use 100% of the code from the bundles.

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

No branches or pull requests

4 participants