to-arraybuffer icon indicating copy to clipboard operation
to-arraybuffer copied to clipboard

Use is-buffer module to reduce bundle size.

Open michaelrhodes opened this issue 9 years ago • 1 comments

Hey there, thanks for writing this module! I’m pretty sensitive about browserify bundle sizes, so I thought I’d point out that you can yield quite a substantial saving by swapping out Buffer.isBuffer for feross/is-buffer (see below).

# Buffer.isBuffer
$ browserify index.js | sizeist
.js 36.06 kB
.min.js 16.9 kB
.min.js.gz 5.19 kB
# feross/is-buffer
$ browserify index.js | sizeist
.js 1.86 kB
.min.js 1.03 kB
.min.js.gz 496 B

michaelrhodes avatar Jan 13 '16 19:01 michaelrhodes

When would you use to-arraybuffer when browserify isn't already pulling in the full Buffer module elsewhere? If there's a valid use case I'll merge this.

Also, I should be able to remove the require('buffer') entirely and Browserify should pull in feross/is-buffer automatically, but I was running into some trouble with this. I'll take a look at what's wrong there as well.

jhiesey avatar Jan 14 '16 13:01 jhiesey