Skip to content

fix(text/javascript): Clarify charset validity in HTTP vs HTML contex… #40100

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

Merged
merged 7 commits into from
Jul 7, 2025

Conversation

Shrinivassab
Copy link
Contributor

@Shrinivassab Shrinivassab commented Jun 27, 2025

Description

Updated text/javascript MIME type docs to clarify that charset is valid in HTTP headers.

Motivation

Fixes incorrect documentation that claimed charset is always invalid.

Additional details

Related issues and pull requests

Fixes #39505

@Shrinivassab Shrinivassab requested a review from a team as a code owner June 27, 2025 02:32
@Shrinivassab Shrinivassab requested review from hamishwillee and removed request for a team June 27, 2025 02:32
@github-actions github-actions bot added Content:HTTP HTTP docs size/s [PR only] 6-50 LoC changed labels Jun 27, 2025
Copy link
Contributor

github-actions bot commented Jun 27, 2025

Preview URLs

Flaws (3)

URL: /en-US/docs/Web/HTTP/Guides/MIME_types
Title: Media types (MIME types)
Flaw count: 3

  • unknown:
    • No generic content config found
    • no blog root
    • no blog root
External URLs (4)

URL: /en-US/docs/Web/HTTP/Guides/MIME_types
Title: Media types (MIME types)

(comment last updated: 2025-07-04 10:49:08)

Copy link
Collaborator

@hamishwillee hamishwillee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The point of the original was pretty clear: the only allowed mime type is text/javascript - you shouldn't serve all those other types listed below in the section "Legacy JavaScript MIME types".

That is completely true ^^^, because charset is not a mime type - its an optional parameter to the MIME type. Splitting hairs of course, but to my mind the charset issue is a really minor side point to the mime type, so we should keep that first and forefront.

The way I would handle this is to treat it as such. Start with the original text, then have a comment about where you can and cannot use the charset parameter with the mime type.

Does that make sense?

@Josh-Cena FYI - you had a comment on the linked issue.

@Josh-Cena
Copy link
Member

Yeah this PR shifts the focus to the wrong part. I would simply remove the second paragraph, and mention "MIME type essence" somewhere else other than under text/javascript, because it applies to <style> as well. It appears that the second paragraph is straight incorrect because it implies charset is invalid in Content-Type which I don't think is the case (I could be wrong).

@Shrinivassab
Copy link
Contributor Author

Thank you @Josh-Cena and @hamishwillee for the helpful feedback. I have now made the following updates:

  1. Focused the text/javascript section solely on the valid MIME type as originally intended.
  2. Removed the charset explanation from that section.
  3. Added a new general section about MIME type parameters in HTML, which applies to both <script> and <style> elements.

Let me know if --

  1. The new section's placement or wording should be adjusted
  2. or You would prefer to omit it entirely

Thanks again for guiding this, I really appreciate your time and support! -

@Josh-Cena
Copy link
Member

I will let Hamish continue with the review, but (a) this is not the right place to put it because we are listing MIME types under this section (b) you still didn't remove the incorrect paragraph in the original report.

Shrinivassab and others added 5 commits July 4, 2025 11:27
@hamishwillee hamishwillee force-pushed the fix-js-mime-charset branch from 22e12a4 to 862f4ad Compare July 4, 2025 02:11
@hamishwillee
Copy link
Collaborator

Thanks. I have subedit this to my taste - essentially rewording so that the essence stuff is part of the JS section, where the error was reported.

The previous section added wasn't in the right place IMO (it was about how mime types are used, not "an important MIME type". It also generalized to style types what is about script types - this might apply to styles, but if so, I'd add it to that section.

@Josh-Cena You might want to sanity check this too. If not, I will do so on Monday when I have objectivity again.

Shrinivassab and others added 2 commits July 4, 2025 06:43
Thanks for the updated wording.

Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Copy link
Collaborator

@hamishwillee hamishwillee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hamishwillee hamishwillee merged commit 29ed753 into mdn:main Jul 7, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:HTTP HTTP docs size/s [PR only] 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

charset is not invalid in text/javascript MIME
3 participants