Itay Moav -Malimovka
Itay Moav -Malimovka

Reputation: 53606

What is the proper content type for JavaScript in HTML?

What content type should I use, if any, in an inline JavaScript block inside HTML?

application/x-javascript
text/javascript

Or something else?

Upvotes: 0

Views: 371

Answers (4)

Gumbo
Gumbo

Reputation: 655835

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

Upvotes: 4

Chad Birch
Chad Birch

Reputation: 74658

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).

Upvotes: 1

Paolo Bergantino
Paolo Bergantino

Reputation: 488734

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

Upvotes: 7

Guffa
Guffa

Reputation: 700910

text/javascript

Upvotes: 2

Related Questions