What is a suitable content type header for JavaScript files?

I am delivering a JS response from a PHP file. When setting the Content-Type header to use, application/javascript or text/javascript ?

What is the difference between the two?

+43
javascript php
Oct 21 '10 at 12:25
source share
2 answers

According to the IANA Registered MIME media type list , JS has two registered MIME types; deprecated text/javascript and official application/javascript .

So use application/javascript .

+64
Oct 21 2018-10-21
source share

From Wikipedia to Internet Media Types

application/javascript: JavaScript; Defined in RFC 4329 but not accepted in IE 8 or earlier

There is also legacy text/javascript (which IE probably won't suffocate).

+3
Oct 21 2018-10-21
source share



All Articles