Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 795
Umair Jabbar Avatar asked Oct 21 '10 12:10

Umair Jabbar


People also ask

What is the Content-Type header?

The Content-Type representation header is used to indicate the original media type of the resource (prior to any content encoding applied for sending). In responses, a Content-Type header provides the client with the actual content type of the returned content.

Are there header files in JavaScript?

JavaScript does not have . h files.

What is file Content-Type?

Content type refers to content of a file which is transferred via HTTP and classified according to a two-part structure. This classification is standardized and published by the IANA. An alternate term is MIME type.


1 Answers

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

Thus, use application/javascript.

like image 186
You Avatar answered Sep 20 '22 06:09

You