Skip to content

Latest commit

 

History

History
23 lines (17 loc) · 1.01 KB

lit-with-skypack.md

File metadata and controls

23 lines (17 loc) · 1.01 KB

Loading lit from Skypack

Lit 2 stable was released today, offering a tiny, feature-full framework for constructing web components using modern JavaScript.

The getting started documentation involves a whole lot of npm usage, but I wanted to just drop something into an HTML page and start trying out the library, without any kind of build step.

After some discussion on Twitter and with the help of @WestbrookJ I figured out the following pattern, which loads code from Skypack:

<script type="module">
import { LitElement, html } from 'https://cdn.skypack.dev/lit';
  
class MyEl extends LitElement {
  render() {
    return html`Hello world!`
  }
}
customElements.define('my-el',MyEl);
</script>
<my-el></my-el>

Also relevant: lit-dist.