Summary
Replace moment.js with day.js to reduce JavaScript bundle size. moment.js is deprecated and significantly larger than modern alternatives.
Why
| Library |
Size (minified + gzip) |
Status |
| moment.js |
~67 KB |
Deprecated, in maintenance mode |
| day.js |
~2 KB |
Active development, similar API |
Bundle impact: ~65 KB reduction (moment.js is currently in the vendor chunk)
Current Usage
// src/react/utils/extendedMoment.js
import moment from 'moment';
const date = moment(timestamp).fromNow();
Used for:
- Relative timestamps ("5 minutes ago")
- Date formatting in entries
- Locale-aware date display
Migration Path
// After
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
dayjs.extend(relativeTime);
const date = dayjs(timestamp).fromNow();
Potential Issues
- Locale handling - day.js loads locales separately (good for bundle size, but needs explicit import)
- Plugin system - Some moment features require day.js plugins:
relativeTime - for .fromNow()
localizedFormat - for locale-aware formatting
utc - for UTC operations (if used)
- API differences - Minor, but need to verify all usages:
- Both use
.format(), .fromNow(), .diff()
- day.js is immutable by default (moment mutates)
Tasks
References
Summary
Replace moment.js with day.js to reduce JavaScript bundle size. moment.js is deprecated and significantly larger than modern alternatives.
Why
Bundle impact: ~65 KB reduction (moment.js is currently in the vendor chunk)
Current Usage
Used for:
Migration Path
Potential Issues
relativeTime- for.fromNow()localizedFormat- for locale-aware formattingutc- for UTC operations (if used).format(),.fromNow(),.diff()Tasks
npm install dayjssrc/react/utils/extendedMoment.jsnpm uninstall momentReferences