Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jQuery minify issue with new hugo v0.113.0+extended #11132

Closed
tfsojon opened this issue Jun 19, 2023 · 12 comments · Fixed by #11138
Closed

jQuery minify issue with new hugo v0.113.0+extended #11132

tfsojon opened this issue Jun 19, 2023 · 12 comments · Fixed by #11138

Comments

@tfsojon
Copy link
Contributor

tfsojon commented Jun 19, 2023

This issue with the latest release.

{{ $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

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" }}
@bep
Copy link
Member

bep commented Jun 19, 2023

Do you any info about the last version of Hugo this was OK?

@bep bep added this to the v0.114.0 milestone Jun 19, 2023
@bep
Copy link
Member

bep commented Jun 19, 2023

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

@bep
Copy link
Member

bep commented Jun 19, 2023

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.

@tfsojon
Copy link
Contributor Author

tfsojon commented Jun 19, 2023

I'm setting up a theme and will link the repo to this issue.

@tfsojon
Copy link
Contributor Author

tfsojon commented Jun 19, 2023

@bep
Copy link
Member

bep commented Jun 19, 2023

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

@jmooring
Copy link
Member

jmooring commented Jun 19, 2023

@tfsojon How do I reproduce the problem with the repo you linked to?

Disregard.

@jmooring
Copy link
Member

jmooring commented Jun 19, 2023

While reducing this to a simple example, I found that the problem is exposed when the minified resource is rendered inline (see original code).

For example, this fails:

<script>{{ $js.Content | safeJS }}</script>

This does not fail:

<script src="{{ $js.RelPermalink }}"></script>

This may be an encoding issue, perhaps related to tdewolff/minify@9fbf910 or tdewolff/minify@7d47c2c.

Google Chrome and Firefox behave identically.


Minimal example:

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:

hugo server --disableLiveReload

@jmooring
Copy link
Member

I can confirm that was fixed with tdewolff/minify v2.12.7. Verified against @tfsojon's test repo, as well as the minimal example above. Tested with minified script inline and external.

@tfsojon
Copy link
Contributor Author

tfsojon commented Jun 20, 2023

Thank You. Issue Solved with v0.114.0

@tfsojon tfsojon closed this as completed Jun 20, 2023
@bep
Copy link
Member

bep commented Jun 20, 2023

v0.114.0 was a ... workaround.

@bep bep reopened this Jun 20, 2023
@bep bep modified the milestones: v0.114.0, v0.114.1 Jun 23, 2023
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants