3

I was reading a tutorial on HTML 5 Canvas Animation with javascript (of course). In the header, the author used
application/javascript which is rather new to me because I've only seen text/javascript used. Can anyone help? There is every likelihood this question has been asked before but I'm using a phone to do this so I can't see any similar questions.

Thanks

afaolek
  • 8,452
  • 13
  • 45
  • 60
  • possible duplicate of [What is the Javascript MIME Type? What belongs in the type attribute of a script tag?](http://stackoverflow.com/questions/189850/what-is-the-javascript-mime-type-what-belongs-in-the-type-attribute-of-a-script) – Jon Mar 26 '12 at 10:27
  • I don't know the difference but I know that HTML5 default value for `type` attribute on `script` element is `text/javascript` http://www.w3.org/TR/html5/scripting-1.html#attr-script-type – pomeh Mar 26 '12 at 10:29
  • And someone could use also application/x-javascript. Anyway, the browsers are tolerant and it might no matter. – antonjs Mar 26 '12 at 10:31
  • surprisingly all the answers are similar to this guy's answer :p http://stackoverflow.com/questions/876561/when-serving-javascript-files-is-it-better-to-use-the-application-javascript-or – Andreas Wong Mar 26 '12 at 10:45

2 Answers2

2

application/javascript is the correct MIME type for Javascript, although text/javascript shouldn't cause any issues

Adam Hopkinson
  • 28,281
  • 7
  • 65
  • 99
2
  • text/javascript - is obsolete
  • application/javascript - MIME type for JS

Guidelines:

  • Use application/javascript on the server to return MIME type
  • Use text/javascript for type attributes of <script> tag although it's not really required
Andreas Wong
  • 59,630
  • 19
  • 106
  • 123