digitalbazaar / hashlink

JavaScript implementation of Cryptographic Hyperlinks specification.
https://tools.ietf.org/html/draft-sporny-hashlink
BSD 3-Clause "New" or "Revised" License
13 stars 3 forks source link

Investigate reducing package size #13

Open coderintherye opened 5 years ago

coderintherye commented 5 years ago

"The package size is a bit chunky due to the CBOR implementation (80KB), but we can get that down over time given enough cycles to remove the unnecessary node.js Buffer polyfills that the CBOR implementation required."

This issue is to investigate what changes can be made to reduce package size and then spin those out into individuals issues to implement with code changes. Chief among them would be what Manu pointed out as the CBOR implementation size being large due to polyfills. It might be helpful to indicate which versions of modern browsers this is targeting in order to understand which polyfills are necessary. However, perhaps it is possible to just produce a CBOR implementation that doesn't require polyfills for modern browsers?

davidlehn commented 5 years ago

The main issue is that most of the modern up-to-date CBOR packages are using Node.js Buffers. That requires a polyfill in browsers. Ideally, they would be using TypedArray features (Uint8Array, etc) that are natively supported in Node.js and browsers. Porting one of the libs to use TypedArrays is possible, it'll just take some time.