Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

domino example

Domino is an implementation of the document object model that you can use to build "webpages" without requiring a browser or a heavy browser-like abstraction.

If you need even less DOM-compatibility and just want to parse some HTML, cheerio is an even more lightweight abstraction that works great.

1
2
3
4
5
6
7
8
9
10
11
export let dominoDomExample = (async () => {
const { default: domino } = await import("npm:domino");
const document = domino.createDocument();
document.body.innerHTML = "<div class=\"container\"></div>";
const container = document.querySelector(".container");
const button = document.createElement("button");
button.textContent = "click me!";
button.id = "the-button";
container.appendChild(button);
return document.body.innerHTML;
})();
October 23, 2023