v0.9.0
guide / Pages drawn by JavaScript

Pages drawn by JavaScript

Some sites send an almost empty page and draw everything with JavaScript — the

v0.9.0 13 / 21 2 min read docs/GUIDE.md

1. It recognises the page. An empty (or “Loading…”) mount point such as #root, #app or <app-root>, a <noscript> asking for JavaScript, a module script on a bare page, or a page with scripts and hardly any text.

2. It looks for a text version. If the page advertises one (<link rel="alternate" type="text/markdown">), wr reads that.

3. It renders the page, if it can. With a Chromium or Chrome installed (chromium, chromium-browser, google-chrome, brave-browser, microsoft-edge… on your PATH, or the one named in WR_BROWSER), wr loads the page in a headless instance and reads the result like any other page. The loading screen and the footer say rendering with the browser…; it takes a few seconds and is cut off after 30. The browser runs with its sandbox on and a throwaway profile that is deleted afterwards, and the rendered page is cached like any other.

4. Otherwise it tells you, and shows what it has. The page’s own summary (its <noscript> text, description and JSON-LD) appears under a notice that says what to do: install a browser, turn render_js back on, or open the page with x. This version is not cached, so the page renders properly once a browser exists.

What this cannot do: pages behind a login, sites that turn away automated browsers (the “Just a moment…” walls), and content that only appears after you click something. x opens the page in your real browser, and wr --md URL shows the Markdown wr ended up with.

It is your call. Rendering runs the site’s own scripts, and whatever network requests they make, inside that headless browser. If you would rather not load a site’s scripts at all, turn it off: Render JavaScript pages in Settings, render_js = false, or WR_BROWSER=/nonexistent. Pages drawn by JavaScript then show their summary and the notice.