100 words
1 minute
Loading lit from Skypack
Anubhav Gain
2024-08-05

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.

Loading lit from Skypack
https://mranv.pages.dev/posts/loading-lit-from-skypack/
Author
Anubhav Gain
Published at
2024-08-05
License
CC BY-NC-SA 4.0