2

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 answers such as this or this.

What MIME type should I use when serving javascript content?

7

1 Answer 1

6

The MDN article links to the WHATWG (Web Hypertext Application Technology Working Group, which consists of people from Apple, Google, Mozilla, Microsoft and others) HTML Living Standard that was last updated a few days ago. This is the current most up to date HTML specification and it says text/javascript.

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.

In reality though no browser will break on either text/javascript or application/javascript so it doesn't really matter. For new projects I would definitely use text/javascript but I won't go back and update my old ones.