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?
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.
JavaScript does not have . h files.
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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With