🏗️🚀:minify the script the site serves - #1867
Conversation
✅ Deploy Preview for gh-pages-openinf ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe build now post-processes generated SVG and JavaScript assets. SVG optimization remains unchanged. JavaScript uses Terser with preserved attribution comments and an original-content fallback. ChangesAsset processing
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The change is merge-ready after normal checks and review; no actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Linked Issues checkExplanation The PR implements the JavaScript asset-processing portion requested by issue Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
The counter shipped as it is written upstream, comments and all. It is squeezed on the way out instead: 9,213 bytes to 5,774, and 3,327 to 2,263 once gzipped, which is the figure that counts. The copy in the repository is untouched, which is what lets both things be true at once: a reader downloads the small one, and the one here stays byte for byte what upstream serves, so `nps verify.vendored` can still tell whether it has fallen behind. A minifier drops comments, and the two lines this one opens with are its terms rather than decoration -- ISC asks for the notice in every copy. They are kept, along with anything marked `@license` or `@preserve`. Images and scripts are both copied rather than rendered, so neither meets a transform; the pass over the output now knows what to do with each. That leaves nothing served here that is not squeezed: markup, styles, marks and now this. Signed-off-by: Derek Lewis <DerekNonGeneric@inf.is> Assisted-by: Claude-Code:claude-opus-5 Fixes: #1548
98d73eb to
7946f9f
Compare
The stylesheet is built on the rule that `.min` is a claim about what is inside a file, so only the build that minifies makes one. The script was minified under the name it arrived with, which says the opposite of what had happened to it. It is `count.min.js` now, and the unminified copy does not go out beside it. The tag asking for it sits inside the block that only renders for production, so it names the minified file outright rather than deciding again in a condition that cannot be false. Signed-off-by: Derek Lewis <DerekNonGeneric@inf.is> Assisted-by: Claude-Code:claude-opus-5 PR-URL: #1868 Refs: #1867
The counter script shipped exactly as it is written upstream, comments
and all. It is squeezed on the way out now — and the copy in the
repository is untouched, so both things stay true at once.
Why the source has to stay as it is
nps verify.vendoredand the weekly watcher from #1865 tell whether thevendored copy has fallen behind by comparing it to what upstream serves.
That only works while it is byte for byte upstream's. Minifying in place
would have traded a 1KB saving for the ability to notice the next
sixteen months of drift.
The license notice is not decoration
A minifier drops comments. The two lines this script opens with are its
terms:
ISC asks for the notice in every copy, so stripping it from a file we
redistribute would not be a tidy-up. Confirmed that the default does
strip it, and that what ships keeps it:
Anything marked
@licenseor@preserveis kept on the same rule.One pass, two kinds of asset
Images and scripts are both copied rather than rendered, so neither
meets a transform. The pass over the output now dispatches on extension
rather than assuming everything it finds is a mark.
That closes #1548
The issue asked for post-processing of every asset that could benefit.
All four now are:
html-minifier-tersersvgo, inline and as filescssnanoterserVerified
public functions present, and
goatcounter.url()produces a beaconwith
s=390 p=/236,141 — so refactoring the shared pass disturbed nothing
viewBoxintact on all 8 filesnps testpassesterser@5.50.0is the versionhtml-minifier-terseralready resolves,so this declares what is there rather than adding a second copy.
Fixes #1548
Summary by CodeRabbit