Skip to main content Accessibility Feedback

Vanilla JavaScript Boilerplates

Last week, I added a collection of boilerplates to the Vanilla JS Toolkit.

It’s a collection of templates to help you kick-start your next vanilla JS project. It includes three patterns for scoping your code:

  1. The Immediately Invoked Function Expression (or IIFE)
  2. The Revealing Module Pattern
  3. The Universal Module Definition (or UMD)

Within the Revealing Module Pattern and UMD, you can also decide to allow users of your plugin to pass in their own options, and optionally use a constructor pattern to allow multiple instances of a script to run at once.

The Toolkit covers these topics at a high level, but if you want to deep-dive into how to structure flexible, scalable JavaScript projects, you might enjoy my Writing Plugins Pocket Guide.