Skip to content

v2.20.0

Latest

Choose a tag to compare

@gildas-lormeau gildas-lormeau released this 27 Oct 12:02

SingleFile CLI 2.20.0

New features

  • New option --remove-unused-glyphs (experimental, off by default): the glyphs the page does not draw are removed from the embedded TrueType, WOFF and WOFF2 fonts. The characters kept are those the page text, the CSS-generated content, the list markers and the text-transform values draw, plus their canonical decompositions and compositions, their bidi mirrors and their variation selectors, so a font that shapes them with ligatures or marks keeps the glyphs it needs. A font is left untouched when it is a CFF or a variable font, when it declares a MATH table, when the rewritten font is not smaller, or when the browser fails to load it. On the sites tested the saved page shrinks by 3% to 30% (nytimes.com: 14.0 MB to 9.9 MB). With the Chromium engine the WOFF2 fonts are compressed with Node's Brotli at maximum quality; with the Firefox engine the browser's own Brotli streams are used.

CLI fixes and improvements

  • Update single-file-core to 1.7.0:
    • New %titlecase template function for filenames: the first letter of every word is uppercased, the other letters are left as typed.
    • Whitespace runs in a filename are collapsed to a single space after the replacement rules are applied, so a removed character no longer leaves a double space behind.
    • The filename replacement rules now match characters outside the Basic Multilingual Plane, so a rule written to remove emojis removes every one of them.
    • The repair of invalid nesting no longer drops the text between displaced siblings: a sentence built as <div> blocks inside a <p>, one per word, separated by spaces, was saved without its spaces.
    • A styled XML document no longer hangs the capture.
    • A page holding a very large amount of text no longer fails with RangeError: Invalid array length in the "remove unused fonts" step.
    • A stylesheet modified by the page's scripts and read back through its CSSOM serialization no longer loses the rules under a media or container query whose value Firefox serializes as infinity * 1px, the way styled-components writes an open-ended last breakpoint. The value is now written as the largest finite length, which every browser reads back.
    • New zipWorkerURI init option for the hosts embedding core; nothing changes for the CLI.

Co-authored by Claude (Claude Code)