Opened 6 years ago

Last modified 4 months ago

#1407 reopened enhancement

Should application/javascript be text/javascript in mime.types

Reported by: henrik.gemal.dk@… Owned by:
Priority: minor Milestone:
Component: other Version: 1.13.x
Keywords: Cc:
uname -a: Linux ip
nginx -V: nginx version: nginx/1.12.1

Description

I think the 'content-type' header for js files should have media type 'text/javascript' (not 'application/javascript')

nginx version: nginx/1.12.1

Change History (6)

comment:1 by Valentin V. Bartenev, 6 years ago

Resolution: invalid
Status: newclosed

Why do you think so?

According to RFC 4329 (April 2006):

Use of the "text" top-level type for this kind of content is known to
be problematic. This document thus defines text/javascript and text/
ecmascript but marks them as "obsolete". Use of experimental and
unregistered media types, as listed in part above, is discouraged.
The media types,

  • application/javascript
  • application/ecmascript

which are also defined in this document, are intended for common use
and should be used instead.

comment:2 by sideshowbarker@…, 6 years ago

Why do you think so?

See https://tools.ietf.org/html/draft-ietf-dispatch-javascript-mjs-00#section-4.2

This document proposes updates to the ECMAScript media types,
superseding the existing registrations for "application/javascript"
and "text/javascript"

In particular see:

And see also https://html.spec.whatwg.org/multipage/scripting.html#scriptingLanguages:

Servers should use text/javascript for JavaScript resources. Servers should not use other JavaScript MIME types for JavaScript resources, and must not use non-JavaScript MIME types.

comment:3 by JakubJanowski@…, 19 months ago

Resolution: invalid
Status: closedreopened

RFC 4329 has now been obsoleted by RFC 9239 which states in section 6.1.1 that application/javascript mime type has been deprecated and text/javascript should be used.

comment:4 by Maxim Dounin, 19 months ago

Type: defectenhancement

See also ticket #2216 and this thread:

https://mailman.nginx.org/pipermail/nginx-devel/2022-May/7PN54GRH2S4ESBBTUTGZDXEKPEZGCWOJ.html

Some quotes from the thread:

As for the MIME type change from "application/javascript" to 
"text/javascript", this is something we'll consider as the outcome 
of the change suggested by the RFC becomes more clear.  For now, 
it looks like this might need more compatibility shims (such 
as adding both "text/javascript" and "application/javascript" to 
the default list of types handled by the charset module) and more 
changes (such as change of the MIME type used by autoindex with 
JSONP format).
In this particular case, the RFC itself talks about "text/*" being 
an incorrect, and only used because "the industry widely adopted 
text/* anyway".  On the other hand, httparchive.org data suggests 
that "application/javascript" is more popular now than 
"text/javascript":

Query:

SELECT
  mimeType,
  COUNT(distinct pageid) total_pages,
  COUNT(0) total_requests
FROM
  `httparchive.summary_requests.2022_03_01_desktop`
GROUP BY
  mimeType
ORDER BY
  total_requests DESC

Results:

Row	mimeType	total_pages	total_requests	
1	application/javascript 5346744 95187099
2	image/jpeg 4608713 78732193
3	image/png 5129850 58321805
4	text/css 5546313 56797104
5	text/html 5718485 41375375
6	text/javascript 4670822 36042510
...
11	application/json 3641048 16939555
12	application/x-javascript 2577400 14903323
...

From the rationale provided in the RFC it is not clear why 
"application/javascript", which is more popular, was dropped in 
favor of the "text/javascript", which is incorrect and less 
popular.

Overall, this is something to consider as the outcome of the change suggested by the RFC becomes more clear.

Last edited 15 months ago by Maxim Dounin (previous) (diff)

comment:5 by Maxim Dounin, 4 months ago

For the record: RFC 9204, "QPACK: Field Compression for HTTP/3", uses application/javascript in static table.

comment:6 by Maxim Dounin, 4 months ago

For the record, HTTP Archive data as of httparchive.summary_requests.2023_10_01_desktop, otherwise the same query:

Row     mimeType total_pages total_requests
1       application/javascript 11846255 227387962
2       image/jpeg 9856195 147832918
3       text/css 12317159 139579364
4       image/png 11143451 116073400
5               6706412 101980466
6       text/html 12840076 98692496
7       image/gif 7628026 82149680
8       text/javascript 9366878 78538446
9       application/json 7757207 50520165
10      font/woff2 9110984 45917270

Does not look like there are major changes since comment:4.

Note: See TracTickets for help on using tickets.