When importing the full UMD version of Dinero.js, the development build is 84.8 KB, the minified version is 29.8 KB, and the compressed versions are 4.4 KB with Gzip and 3.8 KB with Brotli.
Development | Minified | Gzip | Brotli | |
---|---|---|---|---|
dinero.js | 84.8 KB | 29.8 KB | 4.4 KB | 3.8 KB |
@dinero.js/currencies | 20.4 KB | 6.6 KB | 1.4 KB | 1.0 KB |
@dinero.js/core | 47.0 KB | 15.2 KB | 3.8 KB | 3.3 KB |
@dinero.js/calculator-number | 4.6 KB | 1.2 KB | 0.6 KB | 0.6 KB |
@dinero.js/calculator-bigint | 4.3 KB | 1.0 KB | 0.6 KB | 0.5 KB |
The size of dinero.js
includes the one of its dependencies @dinero.js/core
and @dinero.js/calculator-number
.
Copy linkCompress your assets
If you're using the UMD build, make sure to compress it before you serve it in production.
If you're importing Dinero.js via a CDN such as jsDelivr or cdnjs, you should get Gzip or Brotli compression out of the box. If you're hosting your own, make sure to use the production build and to compress it either manually or using an edge server like Cloudflare or Cloudfront.
Copy linkUse the ESM build
Dinero.js comes in two builds: Universal Module Definition (UMD) and ECMAScript Modules (ESM).
The UMD build bundles the entire library. It's meant for usage in Node.js 13.1 or older (before ES modules support), or when your web project doesn't use a build system.
If you're using a modern build system like webpack, Parcel or Vite, you should use the ESM build and bundle it yourself. This lets you take advantage of performance features like tree-shaking and code splitting.
Copy linkTree-shake your code
Tree-shaking lets you bundle only the code you're using and eliminate the rest. For example, if you're only using Dinero.js to add and subtract monetary values, only dinero
, add
, subtract
, and their dependencies should be in your final bundle.
Dinero.js is a pure library, meaning it doesn't produce side-effects. If you're using a modern build system, you can tree-shake it. To do so, make sure to import only the functions you need, and enable tree-shaking in your bundler configuration if necessary.
import { dinero, add, subtract } from 'dinero.js';
import { USD } from '@dinero.js/currencies';
// ...