Repository: gohugoio/hugo (language: go)

Issue:
jQuery minify issue with new hugo v0.113.0+extended
<!-- Please answer these questions before submitting your issue. Thanks! -->

### This issue with the latest release.

- Using Hugo (`v0.113.0+extended`)
- [jquery-3.7.0.js](https://code.jquery.com/jquery-3.7.0.js)
```
{{ $scripts := slice }}
{{ range site.Params.plugins.js}}
{{ $scripts = $scripts | append (resources.Get .link) }}
{{ end }}
{{ $scripts = $scripts | append (resources.Get "js/script.js") }}
{{ $scripts = $scripts | resources.Concat "/js/script.js" | minify | fingerprint "sha512" }}
```

![image](https://github.com/gohugoio/hugo/assets/87603786/e347df59-8964-4569-92d0-47186c99f1e6)

### without minify its working

```
{{ $scripts := slice }}
{{ range site.Params.plugins.js}}
{{ $scripts = $scripts | append (resources.Get .link) }}
{{ end }}
{{ $scripts = $scripts | append (resources.Get "js/script.js") }}
{{ $scripts = $scripts | resources.Concat "/js/script.js" | fingerprint "sha512" }}
```



Discussion / hints:
Do you any info about the last version of Hugo this was OK?
Yes, this is a bug and needs to be fixed, but I think you would get a better JS setup if you rewrote the above to use 

* https://gohugo.io/hugo-pipes/js/
* which supports imports directly from `assets` (e.g. your jquery)
* has an option for minification


I just quickly tested this with that jQuery version and even minified it worked OK (I just ran some basic jquery examples found online) ... Which I guess it means that there's a certain part of jQuery that you use that somehow gets mingled. Which means that the upstream author probably needs some more info.
I'm setting up a theme and will link the repo to this issue.
@bep https://github.com/tfsojon/jquery-hugo
Not that it makes any difference in this case (it fails also starting with the unminified jQuery source), but doing minification on already minified JS sources is not something I would recommend. 

As to this issue, I'm reverting the upstream library to a working version for Hugo 0.114 (out soon).
~~@tfsojon How do I reproduce the problem with the repo you linked to?~~

Disregard.
While reducing this to a simple example, I found that the problem is exposed when the minified resource is rendered inline ([see original code](https://github.com/tfsojon/jquery-hugo/blob/main/themes/jquery-hugo/layouts/partials/script.html#L30)).

For example, this fails:

```html
<script>{{ $js.Content | safeJS }}</script>
```

This does not fail:

```html
<script src="{{ $js.RelPermalink }}"></script>
```

This may be an encoding issue, perhaps related to https://github.com/tdewolff/minify/commit/9fbf9105be774ca8d4174c54f08525c799269319 or https://github.com/tdewolff/minify/commit/7d47c2c620e37388d39b21db1131b8480ef71df4.

Google Chrome and Firefox behave identically.

---

Minimal example:

```text
git clone --single-branch -b hugo-github-issue-11132 https://github.com/jmooring/hugo-testing hugo-github-issue-11132
cd hugo-github-issue-11132
```

Open the browser's console, then:

```text
hugo server --disableLiveReload
```


I can confirm that was fixed with [tdewolff/minify v2.12.7](https://github.com/tdewolff/minify/releases/tag/v2.12.7). Verified against @tfsojon's test repo, as well as the minimal example above. Tested with minified script inline and external.

Fix patch:
diff --git a/go.mod b/go.mod
index 5df2b0f430b..9ddf6360633 100644
--- a/go.mod
+++ b/go.mod
@@ -61,7 +61,7 @@ require (
 	github.com/spf13/cobra v1.7.0
 	github.com/spf13/fsync v0.9.0
 	github.com/spf13/pflag v1.0.5
-	github.com/tdewolff/minify/v2 v2.12.5
+	github.com/tdewolff/minify/v2 v2.12.7
 	github.com/tdewolff/parse/v2 v2.6.6
 	github.com/yuin/goldmark v1.5.4
 	go.uber.org/atomic v1.11.0
diff --git a/go.sum b/go.sum
index 3f8ad9d2401..e8b4845844c 100644
--- a/go.sum
+++ b/go.sum
@@ -561,13 +561,13 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
 github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
 github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
 github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
-github.com/tdewolff/minify/v2 v2.12.5 h1:s2KDBt/D/3ayE3gcqQF8VIgTmYgkx+btuLvVAeePzZM=
-github.com/tdewolff/minify/v2 v2.12.5/go.mod h1:i8QXtVyL7Ddwc4I5gqzvgBqKlTMgMNTbiXaPO4Iqg+A=
-github.com/tdewolff/parse/v2 v2.6.5/go.mod h1:woz0cgbLwFdtbjJu8PIKxhW05KplTFQkOdX78o+Jgrs=
+github.com/tdewolff/minify/v2 v2.12.7 h1:pBzz2tAfz5VghOXiQIsSta6srhmTeinQPjRDHWoumCA=
+github.com/tdewolff/minify/v2 v2.12.7/go.mod h1:ZRKTheiOGyLSK8hOZWWv+YoJAECzDivNgAlVYDHp/Ws=
 github.com/tdewolff/parse/v2 v2.6.6 h1:Yld+0CrKUJaCV78DL1G2nk3C9lKrxyRTux5aaK/AkDo=
 github.com/tdewolff/parse/v2 v2.6.6/go.mod h1:woz0cgbLwFdtbjJu8PIKxhW05KplTFQkOdX78o+Jgrs=
-github.com/tdewolff/test v1.0.7 h1:8Vs0142DmPFW/bQeHRP3MV19m1gvndjUb1sn8yy74LM=
 github.com/tdewolff/test v1.0.7/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
+github.com/tdewolff/test v1.0.9 h1:SswqJCmeN4B+9gEAi/5uqT0qpi1y2/2O47V/1hhGZT0=
+github.com/tdewolff/test v1.0.9/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
 github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
 github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo=
 github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=


Test patch: