A page of web components shows nothing until its scripts have run. A prerendered page has the shadow tree of every component in its markup, as a declarative shadow root, so the browser draws the page as soon as the markup arrives. When the scripts arrive, each component takes over its own tree.
scripts/prerender.mjs makes such a page. It opens a page in a headless Chrome and writes it
back out with the browser's own getHTML. It works for a page with open shadow roots, whatever
it was built with.
Serve the page, then:
node scripts/prerender.mjs http://localhost:8000/page.html page.prerendered.html
It needs Node 22 or later, and Chrome. Set CHROME_PATH when Chrome is not found, and
CHROME_FLAGS for more flags, such as --no-sandbox in a container.
Write the output beside the page it was made from, so the relative URLs in it still resolve.
The script waits until every custom element on the page is defined, and then for two frames.
sync. It is not made again.list.append(row), shows every row twice. A script must bring the page to its state and add
nothing. BareMirror's sync does that: it finds the keyed rows that are there and makes only
the ones that are missing.x-table-row and x-tab included. The script stops and names an
element that is never defined.Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |