tags:

views:

43

answers:

3

I am delivering a JS response from a PHP file, while setting the content-type header which value should I use, application/javascript or text/javascript ?

whats the difference between two ?

+2  A: 

It is application/javascript:

header("content-type: application/javascript");
Sarfraz
my browser while rendering normal javascript files shows the header to be application/javascript
Umair
-1. `application/javascript` is a registered mime type and should be used: http://www.iana.org/assignments/media-types/
You
@You: Oh updated :)
Sarfraz
you shall delete this answer then, it is not of any use
Umair
@Umair: You should accept other answer then :)
Sarfraz
I already have accepted the correct one
Umair
+1  A: 

From Wikipedia on Internet Media Types

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

There is also the deprecated text/javascript (which IE will probably not choke on).

Gordon
+3  A: 

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.

You
Does that really work in MSIE?
some
@some: Wikipedia implies otherwise, but this *is* the correct MIME type. The obsolete one may be used instead, if IE would choke in the correct one.
You