Skip to content

run minifiers on ecmarkup outputs and assets#681

Merged
bakkot merged 7 commits intomainfrom
minifiers
Mar 29, 2026
Merged

run minifiers on ecmarkup outputs and assets#681
bakkot merged 7 commits intomainfrom
minifiers

Conversation

@michaelficarra
Copy link
Copy Markdown
Member

Fixes #222.

File Normal gzip Minified gzip Savings
assets/css/ecmarkup.css 6698 5681 15.2%
assets/css/print.css 3135 2503 20.2%
assets/img/ecma-header.svg 3087 3026 2.0%
assets/img/print-front-cover.svg 141443 141324 0.0%
assets/img/print-inside-cover.svg 4313 3293 23.6%
assets/js/ecmarkup.js 267778 262555 2.0%
out.html 878913 828946 5.7%

Disclaimer: I used AI in the process of making this PR.

@bakkot
Copy link
Copy Markdown
Member

bakkot commented Mar 27, 2026

How'd you pick the minifiers? (or did you just let the AI pick?) e.g. per this page lightningcss does a substantially better job.

@michaelficarra
Copy link
Copy Markdown
Member Author

I picked html-minifier-terser. The AI picked the others. I can swap in lightningcss and see how it does.

@michaelficarra
Copy link
Copy Markdown
Member Author

Unfortunately there's an issue with lightningcss's handling of our non-standard Prince directives in print.css. From https://lightningcss.dev/docs.html,

By default, Lightning CSS is strict, and will error when parsing an invalid rule or declaration. However, sometimes you may encounter a third party library that you can't easily modify, which unintentionally contains invalid syntax, or IE-specific hacks. In these cases, you can enable the errorRecovery option (or --error-recovery CLI flag). This will skip over invalid rules and declarations, omitting them in the output, and producing a warning instead of an error. You should also open an issue or PR to fix the issue in the library if possible.

Notice that it removes them, it doesn't just pass them through unchanged.

Additionally, we can swap out terser for swc, which some people consider better, but I don't really like using html-minifier-terser (which will handle inline JS using terser) but then using swc for external JS. The difference was only 25 bytes on ecmarkup.js. So I don't think we should change any of the chosen minifiers.

Copy link
Copy Markdown
Member

@bakkot bakkot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wfm other than comment

@michaelficarra michaelficarra requested a review from bakkot March 28, 2026 14:17
@bakkot bakkot merged commit ff2f313 into main Mar 29, 2026
2 checks passed
@bakkot bakkot deleted the minifiers branch March 29, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

integrate minifiers to save bandwidth and improve load times

2 participants