DEV Community

Panayiotis Georgiou
Panayiotis Georgiou

Posted on • Originally published at panayiotisgeorgiou.net on

Migrating away from moment.js

Migrating away from moment.js

Moment.js was built for the previous era of the JavaScript ecosystem. The modern web looks much different these days. Moment’s usage is so widespread that it’s impossible to deprecate the current version over time. Check out this post on alternative options Migrating away from moment.js

And in alternative corner…

We started with recommendations from the moment deprecation guide and tossed in some fan favorites to make sure we made the best choice we could. Keep in mind that there was a time constraint, so we couldn’t examine every option. Here’s the list we compiled:

How to choose the correct one ?

It will always go down to project size !

  • moment – 327KB, but also needs moment-timezone (185KB)
    • Total: 513KB
  • date-fns – 37.3 KB, but also needs date-fns-timezone (2KB), and all locales (26 KB)
    • Total: ~64KB
    • Eliminated due to lack of pre-built bundle. We need a single source of truth for IWA, and did not want to have to maintain a build process.
  • day.js – 2KB, but also needs the utc and timezone plugins (4KB), and all locales (26 KB)
    • Total: ~32KB
  • spacetimeZero Dependencies comment in the readme.
    • Total: ~43KB
  • luxon – 71KB, Everything is included, and it relies on the INTL api for locales.

Follow me on Instagram

*That’s it for now. *

If you liked this article, then please subscribe to my YouTube Channel for video tutorials.

You can also find me on Twitter and Facebook.

The post Migrating away from moment.js appeared first on Panayiotis Georgiou.

Top comments (0)

typescript

11 Tips That Make You a Better Typescript Programmer

1 Think in {Set}

Type is an everyday concept to programmers, but it’s surprisingly difficult to define it succinctly. I find it helpful to use Set as a conceptual model instead.

#2 Understand declared type and narrowed type

One extremely powerful typescript feature is automatic type narrowing based on control flow. This means a variable has two types associated with it at any specific point of code location: a declaration type and a narrowed type.

#3 Use discriminated union instead of optional fields

...

Read the whole post now!