This site runs best with JavaScript enabled.

How to Write a JavaScript Library

Software Engineer, React Training, Testing JavaScript Training

There are so many reasons to open source your code. But knowing how to do it can be a real challenge.

There's a lot of steps to creating and maintaining an open source library. It's like becoming a parent. Open source libraries can be quite demanding, impatient, and time consuming.

Some libraries are small enough that they're pretty easy to create and don't need to be maintained when they're "done." However, once your lib gets to be more than just a few dozen lines of code, you're going to be faced with some challenges in developing, documenting, releasing, updating, and maintaining your library.

Even with all of these challenges, it's still totally worth it to open source your library. Whether it's the next big JavaScript framework or a simple utility, we welcome your contributions.

Getting started...

I've created a free series on egghead.io that's intended to help you open source your stuff. I start at the very very basics and get you up to speed with the latest and greatest practices for developing open source libraries. The series is still being developed and there are a lot of lessons in the pipeline waiting to be published. But here are a few of the concepts you'll learn from this series:

  • Setting up GitHub for hosting
  • Setting up npm for publishing
  • Creating the lib and adding dependencies
  • Releasing to npm and GitHub
  • Releasing new and beta versions
  • Unit testing and code coverage
  • Setting up continuous integration
  • Automating the release process
  • Code linting
  • Adding githooks to help prevent mistakes
  • Getting contributors
  • Adding a transpiler for ES6 support
  • Creating an Isomorphic/Universal/Portable JavaScript Library
  • Documentation
  • And more!

Not all libraries need all of this, but many would benefit from having this. If you're curious, check out the (free) lesson series on egghead.io: How to Write a JavaScript Library. Start writing more open source JavaScript today! 👍

If you have any recommendations or questions, catch me on Twitter.

Discuss on TwitterEdit post on GitHub

Share article
loading relevant upcoming workshops...
Kent C. Dodds

Kent C. Dodds is a JavaScript software engineer and teacher. He's taught hundreds of thousands of people how to make the world a better place with quality software development tools and practices. He lives with his wife and four kids in Utah.