home ~ socials ~ projects ~ rss

Basic Light DOM Web Component Example

February 2025
class ExampleWidget extends HTMLElement {
  constructor() {
    super();
  }

  connectedCallback() {
    const fragment = new DocumentFragment();
    fragment.append("Hello, world");
    this.appendChild(fragment);
  }
}

customElements.define('example-widget', ExampleWidget)
end of line
Share link:
https://www.alanwsmith.com/en/2s/se/n3/gf/?basic-light-dom-web-component-example