Linked Questions

127 votes
5 answers
97k views

What is the javascript MIME type for the type attribute of a script tag? [duplicate]

What is the MIME type of javascript? More specifically, what is the right thing to put in the "type" attribute of a script tag? application/x-javascript and text/javascript seem to be the main ...
defrex's user avatar
  • 16.3k
107 votes
6 answers
27k views

When serving JavaScript files, is it better to use the application/javascript or application/x-javascript

The whole question fits in the title. And to add some context: I'm not asking what is the best according to what the specs are saying, but rather what works the best given the mix of browsers deployed ...
91 votes
3 answers
64k views

NGINX gzip not compressing JavaScript files

All JavaScript files are not compressed by nginx gzip. CSS files are working. In my nginx.conf I have the following lines: gzip on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; gzip_proxied any; ...
user3633186's user avatar
  • 1,540
102 votes
5 answers
141k views

<script> tag vs <script type = 'text/javascript'> tag

I was just wondering, what is the difference between <script> and <script type = 'text/javascript'> Is it different for different webservers? For example,(I know it's incorrect to ...
Lok Jun's user avatar
  • 1,325
53 votes
4 answers
69k views

What is an appropriate content-type header for JavaScript files?

I am delivering a JS response from a PHP file. When setting the Content-Type header which value should I use, application/javascript or text/javascript? What’s the difference between the two?
Umair Jabbar's user avatar
  • 3,636
2 votes
1 answer
3k views

application/javascript or text/javascript

I know this has been asked many many times, but on MDN it states that the correct MIME type to serve javascript as is text/javascript, and all other MIME types are depreciated contradicting most ...
user avatar
3 votes
1 answer
1k views

Chai doesn't recognize content-type "application/javascript"

No matter what my server actually returns, Chai always gives me res.body={} if the content-type is "application/javascript". Here is my server: const http = require('http'); const server = http....
Sergey's user avatar
  • 48.8k
0 votes
1 answer
1k views

emmet for script <script type="text/javascript">

I can't find any emmet for <script type="text/javascript"> is this omitted by emmet ? I can't find on google either.
user310291's user avatar
  • 37.8k
0 votes
1 answer
1k views

RestController method returned Content-Type = application/javascript in Spring 4.3, but application/json in Spring 5.6

I have this method: @RequestMapping(value = "/getValuesAsJson", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public ValuesJsonObject ...
d00d's user avatar
  • 741
0 votes
0 answers
420 views

How can I render script tag with data block in PUG

I'm trying to paste a widget to my site. I'm currently using PUG as my template engine. I'm not sure how the syntax for a datablock should be written. Can someone help me point out what I'm doing ...
Mak Suriya Jacobsen's user avatar
0 votes
2 answers
172 views

Conflicting of standards about the MIME type for javascripts?

RFC4329 and IANA says it's application/javascript, and text/javascript is obsolete. However, HTML standard (by WHATWG) says servers should use text/javascript rather than other obsolete types. Why is ...
Danny Lin's user avatar
  • 2,270
1 vote
0 answers
50 views

What is the CURRENT official/recommended MIME type for Javascript? [duplicate]

I need to know what could be the correct current/future proof Javascript MIME type. References RFC 4329- April 2006, seems to say text/javascript is obsolete and recommends to use application/...
Sebin Benjamin's user avatar