What is the MIME type of javascript?
More specifically, what is the right thing to put in the ‘type’ attribute of a script tag? application/x-javascript and text/javascript seem to be the main contenders.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is a common mistake. The MIME type for javascript wasn’t standardized for years. It’s now officially: ‘application/javascript‘.
The real kicker here is that most browsers won’t use that attribute anyway, at least not in the case of the script tag. They actually peek inside the packet and determine the type for themselves.
So the bottom line is that the type=’text/javascript’ doesn’t do anything as far as the javascript is concerned, but it’s part of the spec for both HTML 4 and XHTML 1.0.