👋 Hey there, I updated some cached content.
An empty package

Why library developers shouldn't worry about JavaScript compatibility

In the plethora of JavaScript modules hosted on npm, you can see almost everything. Full applications, building tools, small modules, polyfills, plugins, the list goes on. Having all kinds of modules to make you feel productive is one thing that makes npm so cool to rely on.

Around those, there are several packages that are already compiled for a given system. Some library authors decide – usually in a goodwill – what browser/node versions the package supports. This way browser/node compatibility is set ahead of time. But it doesn’t feel right.

What library developers should bear in mind is that the end product developer expects all their modules to compile only for the target they want. We can’t know what target that is ahead of time.

The end product usually has more than one library as a dependency. A library setting its own support table makes the end-product developer lose control of their app and what browsers need support. By taking control from builders to decide this, the end result can have lots of polyfills and unnecessary code, leading to poor performance.

Library developers should be agnostic when it comes to browser/node support and use the latest in ECMA standards. It is not their responsibility but the developer building the end product to know what engines and browsers the library needs to support. Only builders should have the final word if that given software should be supported and transpile it accordingly.

CLOSING THOUGHTS

Library developers should focus on making developers feel productive and in control. The end-product developer should use tools available to speed-up their process. Library developers should worry about the developer experience. Product developers about the user experience. The web has a lot of things to think about and library developers should not add more to the stack of things the end-product developer should be worried.

If you plan to make a library, next time consider enjoying the greatest of the latest that JavaScript can offer for your own benefit. Focus on the solution you’re writing for developers’ benefit. Do what is best to make the developers’ life easier and let them do what is best for their product and how much code they need to generate.


Photo of Cezar Augusto

Hi. I'm Cezar Augusto. I write this blog. I like talking about the web platform, performance, standards, and security. You can follow me on GitHub and Twitter.