Get started with custom-elements CDN

BSD-3-Clause licensed

Custom elements are HTML tags extended with new functionality using JS.

Tags:
  • webcomponents

Stable version

Copied!

How to start using custom-elements CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with custom-elements CDN - cdnhub.io</title>
  <script src="https://cdn.cdnhub.io/custom-elements/1.6.0/custom-elements.min.js" defer></script>
</head>
<body>
  <my-element></my-element>

  <script>
    class MyElement extends HTMLElement {
      constructor() {
        super();
        this.attachShadow({ mode: 'open' });
        this.shadowRoot.innerHTML = `
          <style>
            :host {
              display: block;
              width: 100px;
              height: 100px;
              background-color: lightblue;
            }
          </style>
          <p>Hello, I'm a custom element!</p>
        `;
      }
    }

    customElements.define('my-element', MyElement);
  </script>
</body>
</html>
Copied!
Copied!

All versions