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
The send_file function takes an optional mimetype argument.
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.
As of May 2022, MIME type
application/javascript
has become obsolete in favour oftext/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 whileapplication/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
mimetype
argument.send_file
calls werkzeug.utils.send_file that will attempt to guess the MIME type by calling mimetypes.guess_type utilizing the cpython mimetypes libraryFor now users may include
app.config['COMPRESS_MIMETYPES'].append('text/javascript')
in their app until this PR is merged.