Example:
View the source of the above 2 HTML pages. The difference will be visually evident in the beginning of the HTML sources.
With external minification, the code in script tags gets minified too. The inline script is from this partial. The partial is included in single.html layout here.
My site uses strict CSP with hashes for inline scripts. As the inline script when using --minify did not get minified, I started getting CSP failure for that (functionally, the dynamic TOC works on that page for the external minified version, but not for the other).
It would be great if the inline script can get minified too. If not, I'd like to understand (for documentation) why it did not get minified..
minify switches used by Hugo?Thanks!
That the internal minification is different than some external minification, should not come as a surprise.
As I said in the other thread, I'm not working any more short-term on this particular feature, but if you want to investigate, feel free.
That the internal minification is different
More than different.. just trying to understand why inline JS in script tags is not getting minified.
More than different.
Sure, but the statement is a little like "Hugo behaves differently from Jekyll".
See https://github.com/gohugoio/hugo/commit/755d1ffe7a22d8ad83485240ff78cf25d501602f
There may be ways to loosen up the matching here, but taking every "
Most helpful comment
I suggest you match the JS mime type by something similar as to what I use:
m.AddRegexp(regexp.MustCompile("^(application|text)/(x-)?(java|ecma)script$"), jsMinifier), then you don't have to explicitly stateapplication/javascriptfor everyscript.For a full list see https://www.w3.org/TR/html5/semantics-scripting.html#scripting-languages