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

Add text/javascript mimetype #41

Merged
merged 2 commits into from Apr 16, 2023

Conversation

dev-adas
Copy link
Contributor

As of May 2022, MIME type application/javascript has become obsolete in favour of text/javascript. This may explain why one user has reported that their .js files were not being compressed.

The IETF has released RFC 9239 to explain the deprecation. The official list of MIME types posted by the IANA shows that text/javascript is active while application/javascript is obsoleted.

In the backend if Flask is not given a MIME type, it will attempt to guess it. Here is a series of steps that Flask takes to guess the mimetype

  1. The send_file function takes an optional mimetype argument.
  2. send_file calls werkzeug.utils.send_file that will attempt to guess the MIME type by calling mimetypes.guess_type utilizing the cpython mimetypes library
  3. The mimetypes library by default limits to only the official types registered with IANA. The .js file extension in this library maps to text/javascript this is new.

For now users may include app.config['COMPRESS_MIMETYPES'].append('text/javascript') in their app until this PR is merged.

@alexprengere alexprengere merged commit 4493c13 into colour-science:master Apr 16, 2023
0 of 10 checks passed
@alexprengere
Copy link
Collaborator

Thanks! I just had to fix the tests, otherwise it was spot on 😉

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

Successfully merging this pull request may close these issues.

None yet

2 participants