Skip to main content

⬅️  Go back

Simple vanilla JavaScript “component”

If all you want is a few simple components for a small website or app, you can do so without having to fuss with frameworks, transpilation, or build tools. All it takes is the constructor pattern combined with prototype methods.

And yes, you can use the newer class syntactic sugar instead, but then you will have to worry about transpilation for older browsers that do not support the class syntax (namely IE11 and under).