Skip to content

Instantly share code, notes, and snippets.

@DeadWisdom
Created January 20, 2026 19:42
Show Gist options
  • Select an option

  • Save DeadWisdom/e19514a2709a2b37f7406fbc0ed0d224 to your computer and use it in GitHub Desktop.

Select an option

Save DeadWisdom/e19514a2709a2b37f7406fbc0ed0d224 to your computer and use it in GitHub Desktop.
<current-year></current-year> custom element
/** Displays the current year. Usage: `<current-year>this-gets-replaced</current-year>` */
class CurrentYear extends HTMLElement {
connectedCallback() {
this.textContent = new Date().getFullYear().toString();
}
}
customElements.define('current-year', CurrentYear);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment