A directory of brand guidelines: logosearch.link

End of an era

Dom Habersack
Dom HabersackSeptember 16, 2020
An analog alarm clock in front of a two-colored background.
Where one library ends, another one takes over.

Working with times and dates in JavaScript is no fun. The language has a few quirks, like numbering months starting at 0 instead of 1. According to JavaScript, January is month 0 and December is month 11. Timezones based on location and formatting based on language are similarly annoying.

Instead of doing all that date math or formatting ourselves, we can use libraries that do those very well. For the last few years, Moment.js was a popular choice for this functionality. It can parse, validate, manipulate, and display dates and times in any way you want. It’s been reliable, but also pretty heavy. You’d always have to include the full library in your JavaScript, even if you only used a tiny part of it. When we checked what went into our bundle, Moment was one of the main contributors, with no way to reduce the size.

Earlier this week, the team behind Moment declared the project legacy. It will remain available, but they won’t make any significant changes to it. You are free to keep using it forever, but don’t expect any improvements.

In their announcement, they already point to alternatives. In many scenarios, date libraries are not even necessary anymore. The Intl API makes much of the formatting available in JavaScript natively.

We recently moved to date-fns, which offers the same functionality we used from Moment. It is modular, which allows us to use only the features we need without including everything else as well. The move from Moment to date-fns was very easy.

Moment was an excellent choice for years, and the team behind it deserves a lot of praise. Now that there are more modern alternatives, deprecating it is a difficult but good move from them. If you have not made the switch away from Moment yet, now might be a good time.

– Dom

Continue reading

A person holding a spray bottle.
#17January 1, 2020

Declutter those bytes

Getting rid of projects and plans that we will not get back to frees up mental space for things that excite us.

The ruin of a house on an open field in front of a mountain.
#29March 25, 2020

How to write legacy code

No code starts out as unmaintainable legacy we don’t dare to change. All codebases end up there because of a lot of small decisions like these examples.

A printed picture served on a plate.
#32April 15, 2020

Serving WebP images

Web servers can send different files to browsers based on headers in a request. Knowing this, we can send WebP-files only to browsers that support them.

Read all issues →