Performance and size
yuga is about 7 kB minified and brotlied, with time zones and every Intl locale included. Each extension adds only its own code.
The exact numbers change with every commit, so they aren’t written here. The reports page has, for the latest commit on main:
- every test, in Node.js and in Chromium, Firefox and WebKit;
- benchmarks of every function against Day.js, Moment.js, Luxon and date-fns;
- CPU profiles of the benchmarks;
- the size of core and of each extension, with a map of what’s in the bundle.
Every commit, pull requests included, has its own report at https://vitest.igan.dev/yuga/<commit>/ for 30 days.
Why it’s fast
Section titled “Why it’s fast”Temporal is exact but slow to create, so yuga keeps it off the paths code runs most:
- An instance is milliseconds since the epoch, a time zone and a locale. Its
Temporal.ZonedDateTimeis built only when something needs it, such astoTemporal()or calendar arithmetic across a change of clocks. - The system’s time zone and UTC are read off
Date. - Other time zones use offsets cached between their transitions, so
tz()doesn’t build anIntlformatter on each call. - Units (
year(),month()…) are computed once, on the first read, and kept. - Locales are built from
Intlon first use, one list of names at a time.
Why it’s small
Section titled “Why it’s small”- One function per unit accessor, shared by every instance.
- Parsing formats, localized formats, relative time and the rest are extensions, so core doesn’t carry them.
- No locale files:
Intlalready has them.