-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
mime: change JavaScript type to text/javascript #32351
Comments
Sorry, but we're not going to special case MIME types in net/http so that they differ from the types in the mime package. So if we did this, we'd need to change the mime package. But it seems that application/javascript is correct. See for instance https://stackoverflow.com/a/4101763 |
Let me know if I'm missing something, though? |
I'm not sure we're on the same page wrt. to facts, which, in my opinion, are:
As further corroboration https://developers.google.com/web/fundamentals/primers/modules says the same thing:
From the above it follows that per HTML spec, .js files should be served as As far as a possible remedy, there are several options:
|
It’s unclear to me what the benefit is to changing this. Things will break (people check mime types in tests all the time) with seemingly little to no benefit (unless I’m missing something). Will browsers behave differently if you use one over the other? Is there a deprecation event happening soon that will obsolete What is the tangible benefit of changing this? |
@kjk - Any thoughts on Andy's comment ? |
Hey All, As part of standardizing .mjs we are doing an update to the specification for all js related mimes https://datatracker.ietf.org/doc/draft-ietf-dispatch-javascript-mjs/ TL;DR
|
Timed out in state WaitingForInfo. Closing. (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.) |
Reopening as |
Thanks, @agnivade. @MylesBorins what will break as a result of using |
I don’t think we need to worry about things necessarily breaking, but once the spec is updated that mime type will no longer be accurate.
… On Jul 15, 2019, at 7:29 PM, Andrew Bonventre ***@***.***> wrote:
Thanks, @agnivade <https://github.com/agnivade>.
@MylesBorins <https://github.com/MylesBorins> what will break as a result of using application/javascript?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#32351?email_source=notifications&email_token=AADZYVZ7ACCLLL4GGCZRY6LP7UB5FA5CNFSM4HRUYVMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ7H2DI#issuecomment-511606029>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AADZYVZBI3UKTFYIEWO4SHLP7UB5FANCNFSM4HRUYVMA>.
|
Got it. Thanks, Myles. |
Let’s try this as an early-in-cycle change (altering the mime package to serve |
@MylesBorins what is your opinion on specifying the charset? Should the mime type for .js and .mjs be I ask because all other text/* mime types in the mime package specify a utf-8 charset. |
Change https://golang.org/cl/186927 mentions this issue: |
/cc @bmeck about the charset |
there isn't a recommendation officially. Things should be served as UTF-8 for modules and ignores the MIME parameter if it is present. However, I would exclude this parameter unless it is expected to be enforced, as it does have an affect on Script. |
/cc @mikesamuel |
application/javascript is being deprecated per https://datatracker.ietf.org/doc/draft-ietf-dispatch-javascript-mjs/ Specify a charset to be consistent with other text/* mime types. Fixes golang#32351 Change-Id: I7300f6cfdbcf574103764991cb75172a252a3400 Reviewed-on: https://go-review.googlesource.com/c/go/+/186927 Run-TryBot: Andrew Bonventre <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
Change https://golang.org/cl/217122 mentions this issue: |
Updates #32351 Updates #36878 Change-Id: I19f87430f4344dcc6664d8dd1b8adfc67660f099 Reviewed-on: https://go-review.googlesource.com/c/go/+/217122 Reviewed-by: Brad Fitzpatrick <[email protected]>
…pt as golang/go#32351 Former-commit-id: 761be7901fff65ef0ca6e3ea4339ff59f569cf75
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I used
http.ServeFile()
to serve.js
file.What did you expect to see?
According to https://html.spec.whatwg.org/multipage/scripting.html#scriptingLanguages:javascript-mime-type:
What did you see instead?
Currently
.js
files are served withapplication/javascript
Content-Type.Note: currently this simply comes from
mime.TypeByExtension
but I'm not advocating changing the mime type there, as it's a valid JavaScript mime type.http.ServeFile
could special-case mime type for just.js
files.The text was updated successfully, but these errors were encountered: