The Happy JavaScript Module
Frontend engineer
There is a class of JavaScript modules that should be recognized separately from the rest of the frontend ecosystem. They could be called “happy modules” because everything about them brings developer happiness. The criteria for a module to qualify as a happy module is:
Less than 10kb
Zero dependencies
Instantly usable
IDE support
Let’s look at each of these aspects in detail.
Less than 10kb
The final size at runtime must be 10kb or less minified and compressed.
Small modules like this install and download faster making both the developer and user experience better. They get parsed and executed faster too, which not only improves the speed of an app but has a smaller memory footprint. Small size is also an indication the creators of the module are disciplined about the problem scope they’re addressing.
Zero dependencies
The module has no runtime dependencies. None. Nada. Zero.
Modules with zero dependencies preserve flexibility, will never require resolving conflicts, never tie your project down to an outdated peer-dependency, and they don't have unknown security risks or other costs from hitching themselves to a third party. Independent modules are superior in every way to those that have dependencies.
Instantly usable
The module must be installable via CDN (script tag or import) and be immediately ready for production use.
Modules must also be available for install via NPM, but they cannot require any sort of build step or configuration. This makes the module completely accessible and enables the developer to learn and work without speed bumps. The lack of set up and configuration also eliminates the possibility of variation between environments.
IDE support
JSDoc or TypeScript definitions must be included.
Documentation provided by either of those, especially JSDoc, gives developers the information they need when they need it right inside their IDE. This makes learning, using, and debugging the module fast and efficient.
Those four criteria ensure superb performance, maximum compatibility, instant access, and great developer experience. They make developers (and users) happy!
Examples of Happy Modules
There are many “happy” modules available today, hence the need to qualify and set them apart from the rest of the frontend ecosystem. Some notable examples include:
Day.js - immutable date manipulation and formatting library
Underscore.js - functional utility library - a real classic!
Zod - data schema creation and validation library
Immer - immutable data structures with native JavaScript objects
rawjs - collection of data transformer and formatter functions
Velocity.js - animation engine leveraging modern CSS
Mdash - design system, leverages web standards (one of my projects)
validate.js - simple object validation
