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

bundle size? can it be made smaller? #158

Open
NullVoxPopuli opened this issue Jun 21, 2018 · 5 comments
Open

bundle size? can it be made smaller? #158

NullVoxPopuli opened this issue Jun 21, 2018 · 5 comments

Comments

@NullVoxPopuli
Copy link

NullVoxPopuli commented Jun 21, 2018

I'm analyzing my own app looking for things to slim down, and noticed that instascan takes up the most space? (even in development mode!)
image

those sizes are all the gzipped sizes. instascan's index.js is 2.19MB.
I'm guessing most of that is zxing.js ?

Is there anything that can be done?

The QRCode package is quite small:
image
but I know it wouldn't have any image-processing utilities, which I'm sure is the bulk of what zxing.js is doing.

@NullVoxPopuli
Copy link
Author

maybe using jsqr https://github.com/cozmo/jsQR instead of zxing would help?
jsqr is 44.8 KB https://bundlephobia.com/result?p=jsqr@1.0.4
though, this zxing is https://www.npmjs.com/package/@jakedchampion/zxing is 12.1 KB... so I wonder were the bulk of the 380 KB is coming from. :-\

@NullVoxPopuli
Copy link
Author

NullVoxPopuli commented Jun 21, 2018

maybe it's these things:

// https://bundlephobia.com/result?p=babel-polyfill@6.26.0 28.4KB
require('babel-polyfill');
// https://bundlephobia.com/result?p=webrtc-adapter@6.2.1 19.1KB
require('webrtc-adapter');

are those needed?
I also wonder if I'm not minifying as well as bundlephobia is... gonna look into that.
update: my minifying is fine, so I guess I'm just not accounting for a bunch of tiny deps in instascan?

update2:
30.5KB: https://bundlephobia.com/result?p=fsm-as-promised@0.16.0
19.1KB https://bundlephobia.com/result?p=webrtc-adapter@6.2.1
28.4KB https://bundlephobia.com/result?p=babel-polyfill@6.26.0

  • 12.1 KB if using jakedchampion/zxing

So.. I'm still missing a couple hundred KB :-\ hmm

the biggest one is fsm-as-promised -- is that needed?

@ArcanoxDragon
Copy link

I think dropping babel-polyfill is a good idea anyways; it shouldn't be shipped with a module. I'm getting runtime errors because I need to have it loaded on the page before I import instascan, but if I do that, it throws an error about only one instance being allowed when I do finally import instascan.

@sinitsyn-alex
Copy link

The problem is actual.

Without import instascan (Parsed size 500 KB)

2018-12-27 13-52-53

With import instascan (Parsed size 2.22 MB)

2018-12-27 13-51-49

Total Parsed size ~1720 KB

@NullVoxPopuli
Copy link
Author

@sinitsyn-alex I changed to "qr-scanner": "github:nimiq/qr-scanner",

it's a smidge slower, but is much smaller

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

3 participants