Skip to content

Instantly share code, notes, and snippets.

@modster
Created January 5, 2023 05:23
Show Gist options
  • Save modster/d8a35fb2f0c41d2ba9289772bf5ba5cd to your computer and use it in GitHub Desktop.
Save modster/d8a35fb2f0c41d2ba9289772bf5ba5cd to your computer and use it in GitHub Desktop.
PREACT | Vanilla JS, Htm, No Build Step, Tiny File Size
<!DOCTYPE html>
<html lang="en">
<script type="module">
import { h, Component, render } from 'https://unpkg.com/preact?module';
import htm from 'https://unpkg.com/htm?module';
// Initialize htm with Preact
const html = htm.bind(h);
function App (props) {
return html`<h1>Hello ${props.name}!</h1>`;
}
render(html`<${App} name="World" />`, document.body);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment