The "correct" type is application/javascript
according to RFC 4329 (% with% is deprecated ). But modern browsers can understand all of them. The reason why "application" is correct is that the browser will run JavaScript code, and it does not need to be read (as text) - for example, a minified JS is not readable (in most cases), but can be run smoothly.
In other words, if you want to be exact, and use the recommended MIME type, then you should use text/javascript
. I've put the term "correct" above in quotation marks on purpose - all (to my knowledge) modern browsers will treat the response to a request initiated by a application/javascript
as JavaScript, regardless of the Content-Type value in the servers response .
However, it may be that in the future some stricter browser is created, or that a security hole is detected that causes browsers to force the use of the "correct" MIME type, then start using the correct type now can save headaches later.