Skip to content

fix: skip comment-only JS bundles#1857

Merged
markdumay merged 1 commit intomainfrom
develop
Apr 5, 2026
Merged

fix: skip comment-only JS bundles#1857
markdumay merged 1 commit intomainfrom
develop

Conversation

@markdumay
Copy link
Copy Markdown
Collaborator

Hugo resource transformations are lazy — .Content after | minify | fingerprint still returns the pre-transformation string. A bundle that renders to comments only (e.g. googleanalytics.js with GA disabled) passes the len > 0 guard but produces a fingerprint of empty content while hugo server serves the unminified comment, causing an SRI/CSP integrity mismatch and a blocked script.

Strip // and /* */ comments from .Content before checking whether a bundle contains actual code, and skip the <script> tag entirely if nothing remains.

Also updates mod-google-analytics to v2.0.1, which moves the attribution comment inside the conditional block so the template renders to empty when GA is not active.

Hugo resource transformations are lazy — .Content after
| minify | fingerprint still returns the pre-transformation
string. A bundle that renders to comments only (e.g.
googleanalytics.js with GA disabled) passes the len > 0
guard but produces a fingerprint of empty content while
hugo server serves the unminified comment, causing an
SRI/CSP integrity mismatch and a blocked script.

Strip // and /* */ comments from .Content before checking
whether a bundle contains actual code, and skip the
<script> tag entirely if nothing remains.

Also updates mod-google-analytics to v2.0.1, which moves
the attribution comment inside the conditional block so
the template renders to empty when GA is not active.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 5, 2026

Deploy Preview for gethinode-demo ready!

Name Link
🔨 Latest commit 765ac03
🔍 Latest deploy log https://app.netlify.com/projects/gethinode-demo/deploys/69d1fe2aaa70a50008e6c5a9
😎 Deploy Preview https://deploy-preview-1857--gethinode-demo.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.

@markdumay markdumay merged commit c472f84 into main Apr 5, 2026
15 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026

🎉 This PR is included in version 2.2.5 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant