Click here for v1.x documentation.
Dinero.js
Dinero.js version

Optimizing for production

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.

DevelopmentMinifiedGzipBrotli
dinero.js86.7 KB29.3 KB4.5 KB3.9 KB
@dinero.js/currencies20.5 KB6.6 KB1.4 KB1.0 KB
@dinero.js/core49.5 KB14.8 KB3.9 KB3.4 KB
@dinero.js/calculator-number4.3 KB1.1 KB0.6 KB0.5 KB
@dinero.js/calculator-bigint4.1 KB1.0 KB0.6 KB0.5 KB

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';

// ...