DEV Community


Posted on

web3x - TypeScript port of Ethereums web3.js, for tiny builds.

web3x is a port of web3.js to TypeScript. The main driving factor, beyond the need for a clean, robust, modular, type-safe client implementation for the browser and node.js, is build sizes. With web3.js coming in at ~800kb (~230kb compressed), it can have a noticeable impact on user experience on mobile when combined with the multitude of other libraries an application may require. Every little helps.

This new release of web3x focuses on reducing build sizes further. Most Dapps only use the Eth module and expect an end user to use a provider like MetaMask to handle their accounts. In such cases it makes no sense to distribute code for multiple providers, the crypto code for handling accounts in local storage, shh, bzz, etc. By structuring component initialisation properly, tree-shaking will exclude most of the library that isn't required.

A minimal application with web3x that deals with ERC20 contracts via MetaMask will produce a build via webpack of ~162kb (~46kb compressed).

I am committed to maintaining this library going forward to satisfy any user of web3.js. Further, if there are any developers that find web3.js (and web3x) are missing key functionality that means they have to import other libraries, let me know as web3x aims to serve as many use cases as possible.



Top comments (1)

samuelcasey profile image

This is important work. I’m just getting started with web3 and can see the benefits of having better TS tooling for it already. Thanks for doing this, excited to experiment with it in the near future!