Files

2.2 KiB

TerminalSpeed Insights

Check whether a web page reads well in a terminal browser (w3m, lynx, links, elinks and EWW).

Text browsers ignore stylesheets, most inline CSS and all JavaScript. terminalspeed.py reads your HTML and warns about what will break or read badly in there. The rules are not opinion: they come from dumping real HTML with -dump across the five engines and looking at what each one does.

No dependencies, just the Python 3 standard library.

Usage

python3 terminalspeed.py https://your-site.dev/
python3 terminalspeed.py page.html

Example

$ python3 terminalspeed.py https://news.ycombinator.com/

Terminal readability: 55/100  (https://news.ycombinator.com/)

  [ERROR] 2 image(s) with the alt attribute missing: in a text browser the alt IS the content.
  [WARN ] No <meta charset>: declare UTF-8 as an encoding fallback.
  [WARN ] No <h1>: text browsers rely on headings for structure.
  [WARN ] 228 links before <main>: put the content first, navigation last.

It exits with code 1 if there is any ERROR, and 0 otherwise, so you can drop it into CI.

What it checks

  • JavaScript: no terminal browser runs it. Flags inline handlers (onclick, onsubmit...) and forms without a valid action/method.
  • CSS: stylesheets are not read. Flags display:none (neither by class nor, in most engines, inline actually hides) and using color alone to convey information.
  • Images: tells a missing alt (an error, in a text browser the alt is the content) apart from a decorative alt="" (fine).
  • Structure: <title>, <meta charset>, an <h1>, a heading hierarchy without jumps, and content before a mile-long navigation.
  • Tables: data only. A layout table produces an unreadable grid.
  • Forms: action, method and a name on every field.

About the score

The number is a heuristic, not a science. The weights are set by hand: an error costs more than a warning, and informational notices (INFO) do not penalize. What matters is the list of warnings, not the score. A 100 almost guarantees the page reads well; a low number tells you where to look, not that your site is unreadable (Hacker News scores 55 and reads perfectly in w3m).