Vanilla patterns

This website demonstrates some of the common patterns for developing web applications using vanilla JavaScript. The term 'vanilla' is used to describe a plain version of something without adornments and additions. In the context of front end development 'vanilla JavaScript' refers to frameworkless development. The way 'vanilla' is defined by its practitioners ranges from using abstractions that replace frameworks to a more strict definition of not using non-application-specific abstractions. This website shows patterns that are more along the lines of the latter.

Specifically this means you will not find replacements for data binding, component libraries, template engines, and similar. You will instead find various ways to take advantage of features that the browsers offer, such as the template tag, ES modules, custom elements, constraints validation, form API...

If you would like to contribute to this collection or request some pattern, please feel free to file an issue on GitHub.

KISS—Keep it simple, stupid

Although this website showcases patterns, it is not intended to be a definitive guide on how to develop with vanilla JavaScript. The spirit of vanilla JavaScript development is about embracing the available APIs, and doing the simplest thing that works. Whether some approach described in this website is the simplest or not is technically not important. Carefully considering options, developing a feel for unnecessary complexity, and regularly pruning it—these are the guiding principles of the 'vanilla way'.

List of examples

How to read the examples

Each example consists of three parts: HTML, CSS and JavaScript. These technologies are separate by design, and as vanillistas, we embrace this separation. Therefore, do not look at just the JavaScript. Look at the HTML and CSS as well. Some of the examples will use CSS where most developers resort to JavaScript, or rely on and augment the default HTML behaviors, and this is part of embracing the tools at our disposal.

The code base follows certain conventions that are repeated in all examples. To avoid repeatedly explaining them in each example, I will provide the explanations here:

License

This code is released under the terms of the WTFPL2 license. See the LICENSE file for details. You are free to copy any portion of the code and modify it as you wish for any purpose.

Copyright© 2023. Hajime Yamasaki Vukelic. Some rights reserved.