Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Single file Web Component
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Single File Web Component</title>
<template id=single-file>
h1 {
color: red;
<h1>Hello World</h1>
<script type=module>
class HelloWorld extends HTMLElement {
constructor () {
const template = document.getElementById('single-file')
this.attachShadow({ mode: 'open' })
connectedCallback () {
console.log('Why hello there 👋')
customElements.define('hello-world', HelloWorld)
const sf = document.getElementById('single-file')
Copy link

kristoferjoseph commented Nov 2, 2021

@Westbrook That is very promising indeed. Thanks for the info!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment