[PATCH] Correct JavaScript MIME types + extensions per RFC 9239

Mathias Bynens mths at google.com
Mon May 9 09:46:54 UTC 2022


# HG changeset patch
# User Mathias Bynens <mathias at qiwi.be>
# Date 1652088302 -7200
#      Mon May 09 11:25:02 2022 +0200
# Branch fix-js-mime-and-extensions
# Node ID 7944657540c64d92a5bdc3932710c977d984b54d
# Parent  35afae4b3dffff6718c0cab3ceb16b9de207c20a
Correct JavaScript MIME types + extensions per RFC 9239

This patch updates the MIME type configuration per RFC 9239.
https://www.rfc-editor.org/rfc/rfc9239

First, the recommended MIME type is now `text/javascript`:

> The most widely supported media type in use is `text/javascript`; all
> others are considered historical and obsolete aliases of
`text/javascript`.

Second, the `.mjs` extension is now explicitly registered:

> The `.mjs` file extension signals that the file represents a JavaScript
> module. Execution environments that rely on file extensions to
> determine how to process inputs parse `.mjs` files using the Module
> grammar of [ECMA-262].

IANA template: https://www.iana.org/assignments/media-types/text/javascript

diff -r 35afae4b3dff -r 7944657540c6 conf/mime.types
--- a/conf/mime.types Fri Apr 29 17:38:01 2022 +0400
+++ b/conf/mime.types Mon May 09 11:25:02 2022 +0200
@@ -5,7 +5,7 @@
     text/xml                                         xml;
     image/gif                                        gif;
     image/jpeg                                       jpeg jpg;
-    application/javascript                           js;
+    text/javascript                                  js mjs;
     application/atom+xml                             atom;
     application/rss+xml                              rss;

diff -r 35afae4b3dff -r 7944657540c6
src/http/modules/ngx_http_charset_filter_module.c
--- a/src/http/modules/ngx_http_charset_filter_module.c Fri Apr 29 17:38:01
2022 +0400
+++ b/src/http/modules/ngx_http_charset_filter_module.c Mon May 09 11:25:02
2022 +0200
@@ -128,7 +128,7 @@
     ngx_string("text/xml"),
     ngx_string("text/plain"),
     ngx_string("text/vnd.wap.wml"),
-    ngx_string("application/javascript"),
+    ngx_string("text/javascript"),
     ngx_string("application/rss+xml"),
     ngx_null_string
 };
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20220509/9555bdce/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nginx-rfc9239-patch
Type: application/octet-stream
Size: 2122 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20220509/9555bdce/attachment.obj>


More information about the nginx-devel mailing list