Developer shares JavaScript lessons from building a simple counter app with Cloudflare
A developer built a small counter app using vanilla JavaScript, Tailwind CSS, and Cloudflare Workers to practice state encapsulation, DOM event handling, and static app deployment. The project evolved from a constructor function to a class-based approach using JavaScript's private field syntax (#count) to protect state from direct external access. Instead of attaching separate click listeners to each button, the developer used event delegation — a single listener on the parent element — to simplify and future-proof the code. Deployment to Cloudflare Workers initially failed repeatedly because the Wrangler config pointed to the project root, causing node_modules files exceeding 25 MiB to be treated as deployable assets. The fix was straightforward: redirecting the assets directory to the actual build output folder resolved the error and completed the deployment.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in