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

Large package size #138

Closed
nayfin opened this issue Feb 13, 2022 · 6 comments
Closed

Large package size #138

nayfin opened this issue Feb 13, 2022 · 6 comments

Comments

@nayfin
Copy link

nayfin commented Feb 13, 2022

Firstly thank you for this awesome project. I've been POCing something with a few different client-side image compressors and yours has the best API and feature set I've found. My only qualm is that it is quiet a bit larger than most of the others I've found, though I can't figure out why. I looked through the dependencies and source code and see that the package depends core-js which is also a large package, but it looks like your importing from core-js in a tree-shakable way. So I'm confused as to what is causing the bloat.

So I guess this issue is really a few question:

Do you know what is causing the package to be so much larger than similar packages?

Are there future plans to reduce bundle size?

If you have some guidance on this I'd be happy to work a PR to help trim it down.

Thanks again

@toastyghost
Copy link

toastyghost commented Feb 23, 2022

Not sure if this applies to the specific packages you're using, but a lot of the ones I've looked into were HTTP/REST wrappers that were offloading the actual image processing work to an offsite API.

e: which ones, btw?

@seravifer
Copy link

Something change on 1.0.15 that increase the size https://bundlephobia.com/package/browser-image-compression
And everything looks like it was core-js https://github.com/Donaldcwl/browser-image-compression/releases/tag/v1.0.15

@Donaldcwl
Copy link
Owner

Thanks for concerning about the package size, the package indeed increased in size after adding core-js even though tree-shaking has been applied. We decided to remove core-js for polyfill in this project in the next release. By that time, one may need to load polyfill yourself in order to support older browsers.

Such as:

<script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/3.21.1/minified.min.js"></script>

@nayfin
Copy link
Author

nayfin commented Apr 11, 2022

Thanks for the quick response and fix! I'll close the issue.

Donaldcwl added a commit that referenced this issue Apr 12, 2022
@Donaldcwl Donaldcwl mentioned this issue Apr 12, 2022
@Donaldcwl
Copy link
Owner

v2.0.0 is released, and the bundle size is half now.

ref: https://bundlephobia.com/package/browser-image-compression@2.0.0

@nayfin
Copy link
Author

nayfin commented Apr 13, 2022

Thanks again. I can confirm that it's less than half the size now, down by more than 100k . Here are screen shots of Source Map Explorer results
Before fix
image

After
image

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

4 participants