Pure JavaScript Web Components

Architecture and Solution Structure

Press the Up Arrow and Down Arrow keys to increment and decrement the counter.


This project demonstrates how to isolate your HTML rendering and event handlers from the core application logic of your JS web components.

Source Files:

Download the source: architecture.zip


Exercises

Download the code for the counter app, unzip it into a local folder, and set up a web server so you can browse and run the example.

Exercise 1: Modify the counter app so that:

Exercise 2: Modify the counter app so that:


A note about ES modules

This project uses <script type="module"> and ES modules, so it will not work from a file:// URL

You'll need to run a local web server that serves .js files with the application/javascript MIME type - if you don't have one set up, check out rif/spark, a tiny web server written in Go that will turn any folder on your machine into a website.