-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Remove type="application/javascript" type from Analytics #6046
Conversation
This PR removes ` type="application/javascript"` from Google Analytics snippet. If type was to be used it should be ` type="text/javascript"`, but the type isn't needed to be there anyway. REF: - https://google.github.io/styleguide/htmlcssguide.html#type_Attributes - https://codeguide.co/#html-style-script - https://developers.google.com/analytics/devguides/collection/analyticsjs/#alternative_async_tracking_snippet
Hugo uses https://github.com/gohugoio/hugo/blob/master/media/mediaType.go#L133 |
thanks for the reply @bep - fascinating. the link you gave with the MIME types uses MDN as the reference point (https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#textjavascript) and it states clearly there:
and there is a further note:
But then at the top of that article it states that the Internet Assigned Numbers Authority (IANA) is responsible for all official MIME types, and you can find the most up-to-date and complete list at their Media Types page and there it states: So I can see now why you don't want to get into a discussion about what the correct MIME type is! 😄 In any case, removing the type altogether doesn't appear to make a difference to minification with |
Note that there might be more cases like that (Hugo bundles?). |
Yes, I think there are more cases of this -at least with the other Analytics snippets. What's your opinion on this subject @XhmikosR ? ... Incidentally, the thing that flagged this to me was testing Hugo sites with http://webhint.io - but they've just merged a change to stop warning over the use of REF: webhintio/hint#2621 |
I just follow the specs personally. But since Hugo needs the explicit type set for minification to work properly, I'm not sure what else can be done. |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
I can merge this if there is also a test that confirms that the minification is preserved. I assume it is, but it's good to have it confirmed. |
This think the spec in this case says that the type is optional for JS. |
Yeah, it's optional, i.e. not an error, but a warning. https://validator.w3.org/nu/?doc=https%3A%2F%2Fgohugo.io%2F |
I can confirm for certain that minification is preserved without |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR removes
type="application/javascript"
from Google Analytics snippet. If type was to be used it should betype="text/javascript"
, but the type isn't needed to be there anyway.REF: