A short guide showing two approaches to writing UI components in vanilla JavaScript: using a class-based custom element (Web Components API with connectedCallback) versus standalone script functions that manipulate the DOM directly. Both examples build a simple styled paragraph element.
Table of contents
Class component with separate functions.Class with separate functionsSeparate scriptsGet Practicing DatScy’s stories in your inboxReferences2.1K Impressions