instascan
instascan copied to clipboard
bundle size? can it be made smaller?
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!)
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:
but I know it wouldn't have any image-processing utilities, which I'm sure is the bulk of what zxing.js is doing.
maybe using jsqr https://github.com/cozmo/jsQR instead of zxing would help? jsqr is 44.8 KB https://bundlephobia.com/[email protected] 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. :-\
maybe it's these things:
// https://bundlephobia.com/[email protected] 28.4KB
require('babel-polyfill');
// https://bundlephobia.com/[email protected] 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/[email protected] 19.1KB https://bundlephobia.com/[email protected] 28.4KB https://bundlephobia.com/[email protected]
- 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?
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
.
The problem is actual.
Without import instascan (Parsed size 500 KB)
With import instascan (Parsed size 2.22 MB)
Total Parsed size ~1720 KB
@sinitsyn-alex I changed to "qr-scanner": "github:nimiq/qr-scanner",
it's a smidge slower, but is much smaller