views:

229

answers:

4

What type should I use (If at all) in a javascript block inside html?
application/x-javascript
text/javascript

something/other...

+2  A: 

text/javascript

Guffa
+7  A: 

According to the standards you want to use "text/javascript"

Paolo Bergantino
as Gumbo and Chad mentioned, the current recommendation is actually `application/javascript`; I'd suggest `text/javascript` for backwards compatibility, though; and btw: I think `application/x-javascript` is what Apache sends by default for '.js' files...
Christoph
A: 

After following a few links through the standards I've come to RFC 4329 which describes Scripting Media Types. It stats that "text/javascript" is obsolete and says that you should now be using "application/javascript".

Edit: Apparently no version of Internet Explorer supports "application/javascript", see: https://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=338278. So even though "application/javascript" is correct according to the standards, I suppose you need to use text/javascript to compensate for Microsoft's broken browsers (as usual).

Chad Birch
+4  A: 

Beside that application/javascript is the official MIME type of JavaScript , most browsers only accept text/javascript or just ignore the type attribute value.

Gumbo