uhtml v5
.innerHTML()
can take you a loooong way, but there’s a breaking point where it just becomes too tedious to use, too annoying to
deal with event handlers or escaping security. So when you want to generate HTML with JS, most use a framework. But you might not need one. Sometimes it is very fine to organize to your own desires and let uhtml handle rendering + producing the HTML. And the new v5 version has (finally?) made the API less confusing, and in my experience just works.
Here’s a quick example from https://github.com/WebReflection/uhtml:
<!doctype html>
<script type="module">
import { html } from 'https://esm.run/uhtml';
document.body.prepend(
html`<h1>Hello DOM !</h1>`
);
</script>