Skip to content

🏗️🚀:minify the script the site serves - #1867

Merged
openinf-commit-queue[bot] merged 1 commit into
livefrom
feat/minify-js
Aug 26, 2026
Merged

🏗️🚀:minify the script the site serves#1867
openinf-commit-queue[bot] merged 1 commit into
livefrom
feat/minify-js

Conversation

@DerekNonGeneric

@DerekNonGeneric DerekNonGeneric commented Aug 26, 2026

Copy link
Copy Markdown
Member

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.

before after saved
raw 9,213 5,774 3,439 (37.3%)
gzipped 3,327 2,263 1,064 (32.0%)

Why the source has to stay as it is

nps verify.vendored and the weekly watcher from #1865 tell whether the
vendored 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.

$ git status --short -- '*.js'
                                    # nothing

$ nps verify.vendored
`_assets/js/vendor/count.js` matches https://gc.zgo.at/count.js

The license notice is not decoration

A minifier drops comments. The two lines this script opens with are its
terms:

// GoatCounter: https://www.goatcounter.com
// This file is released under the ISC license: https://opensource.org/licenses/ISC

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:

default terser:  "!function(){\"use strict\";window.goatcounter=…
                 licence notice survives: false

what ships:      // GoatCounter: https://www.goatcounter.com
                 // This file is released under the ISC license: …

Anything marked @license or @preserve is 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:

how where
HTML html-minifier-terser #1862
SVG svgo, inline and as files #1863
CSS cssnano already
JS terser here

Verified

  • the script still runs: loads in WebKit with no page errors, all five
    public functions present, and goatcounter.url() produces a beacon
    with s=390 p=/
  • the vendored source is unchanged and still matches upstream
  • SVG and HTML output are byte for byte what they were — 24,850 and
    236,141 — so refactoring the shared pass disturbed nothing
  • viewBox intact on all 8 files
  • vnu passes; nps test passes

terser@5.50.0 is the version html-minifier-terser already resolves,
so this declares what is there rather than adding a second copy.

Fixes #1548

Summary by CodeRabbit

  • Performance
    • Production JavaScript assets are now minified for faster loading.
    • License and attribution comments are preserved in minified files.
    • SVG optimization continues as before.

@netlify

netlify Bot commented Aug 26, 2026

Copy link
Copy Markdown

Deploy Preview for gh-pages-openinf ready!

Name Link
🔨 Latest commit 7946f9f
🔍 Latest deploy log https://app.netlify.com/projects/gh-pages-openinf/deploys/6a8e6348eb18c40008bfcbff
😎 Deploy Preview https://deploy-preview-1867--gh-pages-openinf.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3ae7add3-e0e0-4f2a-8a68-394afe5859d0

📥 Commits

Reviewing files that changed from the base of the PR and between 98d73eb and 7946f9f.

📒 Files selected for processing (1)
  • eleventy.config.mjs

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The 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.

Changes

Asset processing

Layer / File(s) Summary
Compression support
eleventy.config.mjs, package.json
The build adds Terser and defines JavaScript compression with preserved license and attribution comments.
Extension-based asset dispatch
eleventy.config.mjs
Post-build processing selects compressors for .svg and .js files, while skipping directories and unsupported files.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 7946f

The change is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: minification of the JavaScript served by the site. The emojis add noise but do not make the title unclear.
Linked Issues check ✅ Passed The PR implements the JavaScript asset-processing portion requested by issue #1548. It adds post-build minification, selects processing by file extension, preserves license comments, and leaves the ve…
Out of Scope Changes check ✅ Passed The changes are limited to post-build asset processing and the required Terser development dependency. No unrelated code changes are present.
Docstring Coverage ✅ Passed 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…
Full details: Linked Issues check

Explanation

The PR implements the JavaScript asset-processing portion requested by issue #1548. It adds post-build minification, selects processing by file extension, preserves license comments, and leaves the vendored source unchanged.

Full details: Docstring Coverage

Explanation

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
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/minify-js

Comment @coderabbitai help to get the list of available commands.

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
@OpenINFbot OpenINFbot added the 🚀 Status: Commit Queue Land this pull request when its checks pass label Aug 26, 2026
@openinf-commit-queue
openinf-commit-queue Bot merged commit 3657aa3 into live Aug 26, 2026
17 checks passed
@openinf-commit-queue openinf-commit-queue Bot removed the 🚀 Status: Commit Queue Land this pull request when its checks pass label Aug 26, 2026
openinf-commit-queue Bot pushed a commit that referenced this pull request Aug 26, 2026
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
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.

🏗️ post-processing of all assets

2 participants