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 74.3 KB, the minified version is 25.0 KB, and the compressed versions are 3.8 KB with Gzip and 3.3 KB with Brotli.

DevelopmentMinifiedGzipBrotli
dinero.js74.3 KB25.0 KB3.8 KB3.3 KB
@dinero.js/currencies20.4 KB6.6 KB1.4 KB1.0 KB
@dinero.js/core41.0 KB12.7 KB3.3 KB2.9 KB
@dinero.js/calculator-number4.6 KB1.2 KB0.6 KB0.6 KB
@dinero.js/calculator-bigint4.3 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';

// ...