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

Use application/javascript instead of obsolete text/javascript for Content-Type #292

Closed
westonruter opened this issue Jun 9, 2020 · 2 comments

Comments

@westonruter
Copy link
Collaborator

Apparently text/javascript is obsolete and should now be application/javascript. So this should be changed:

@header( 'Content-Type: text/javascript; charset=utf-8' ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.NoSilencedErrors.Discouraged

@westonruter
Copy link
Collaborator Author

westonruter commented Aug 29, 2020

Humm, apparently I'm mistaken. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#textjavascript

image

Apparently we shouldn't be including the charset=utf-8, though? But how else would the browser know the character set?

@westonruter
Copy link
Collaborator Author

Although perhaps this only applies to the type attribute on script tags, and not to the HTTP Content-Type response header.

Nevertheless, nobody has reported this as causing a problem, so there doesn't seem to be a need to change anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant