Kaizen Today I Learned by Ville Säävuori

My Recommended JS/TS Packages - Alleviate Choice Paralysis

One of the challenges of the JS ecosystem is the outrageous number of available packages. This is a continuously maintained list of useful and preferred JavaScript/TypeScript packages that I have personally worked with.

A recommended package on this list has to have:

  1. Good documentation
  2. Healthy maintenance status
  3. Modern codebase (ie. support for treeshaking etc.)

Dates

Preferred: day.js (Github)

Day.js is a great modern alternative to moment.js. It’s small, tree-shakeable, and ships with full TypeScript support. It also has a ton of plugins that will most likely cover all of your needs out of the box.

Date-fns is an equally good alternative to Day.js, use which ever works best for you.

Alternatives: date-fns, luxon

Avoid / deprecate: moment.js

HTTP Queries

Preferred: Axios (Github)

If you need to do HTTP queries from your app, just install Axios and be done with it. Sure, you can save ~6 kb from the bundle if you just use fetch or some tiny wrapper for it but when your project grows, your needs will grow and you’ll end up installing Axios anyway. It’s feature-complete, well documented, fully typed, and production ready – just use it.

Good alternatives: fetch.

Testing (E2E Tests)

Preferred: Playwright (Github)

Playwright is a modern testing and automation tool. It supports all modern browsers and handles non-trivial scenarions like Websockets, file uploads, and multiple tabs as well.

The one thing Playwright does not yet handle is component testing. When you need that, take a look at Cypress.io.

Good alternatives: Cypress.io

Avoid / deprecate: Nightwatch, Selenium

Testing (Unit Tests)

Preferred: Vitest (Github)

Vitest is a super fast unit test framework powered by Vite that requires zero or very little configuration. It has mostly identical features to Jest, only everything is much faster and more modern.

Avoid / deprecate: Jest

Utility Functions

Preferred: Rambda (Github)

Most JS developers know lodash or its predecessor underscore. Nowadays there are much better and modern alternatives. Rambda focuses on functional programming and speed. It has a smaller API but it’s fully typed and super fast. It’s also well documented.

First consider not including any utility library at all. Modern ES has tons of functionality, yyou should try to use the native functions if possible. If you need more, try Rambda.

(Note: Ramda has better documentation but it’s also slower in many cases. If you need a tool like this it’s more likely than not that the milliseconds you save here will be cumulated enough to this to make a difference.)

Good alternatives: Ramda

Avoid / deprecate: lodash, underscore

Tagged with , ,

Published . Last modified .