When importing the full UMD version of Dinero.js, the development build is 86.7 KB, the minified version is 29.3 KB, and the compressed versions are 4.5 KB with Gzip and 3.9 KB with Brotli.
Development | Minified | Gzip | Brotli | |
---|---|---|---|---|
dinero.js | 86.7 KB | 29.3 KB | 4.5 KB | 3.9 KB |
@dinero.js/currencies | 20.5 KB | 6.6 KB | 1.4 KB | 1.0 KB |
@dinero.js/core | 49.5 KB | 14.8 KB | 3.9 KB | 3.4 KB |
@dinero.js/calculator-number | 4.3 KB | 1.1 KB | 0.6 KB | 0.5 KB |
@dinero.js/calculator-bigint | 4.1 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';
// ...