Difference between “text/javascript” & “application/javascript”
Posted on : 04-03-2009 | By : Heidi Hafner | In : Relocation, Web Design
Tags: Tips & Tricks!, Web Design
1
script type=”text/javascript” src=”scripts/anyscript.js”
script src=”scripts/anyscript.js”
However, in my endeavors to write cleaner pages, use new code instead of obsolete or deprecated code, and also to learn Dreamweaver CS4, I set my tag to be:
script type=”application/javascript” src=”scripts/anyscript.js”
Usually I test all my pages before I let my clients know that they’re done… but this time I didn’t. Shortly after releasing them, I found that the javascript, which I use in many pages only worked in Firefox or Safari, but it did not work in Microsoft IE.
I went through all my code trying to figure out what the deal was… you know, looking for the proverbial needle in a haystack! Couldn’t find it. Finally, it occurred to me that I had tried this new thing that Dw offered, type=”application/javascript”. I quickly changed back to my tried and true, type=”text/javascript”.
Apparently, The W3C (HTML) specification suggests using text/javascript instead of application/javascript.
I found a post by Microsoft that says, “This is an expected by-design behavior. IE currently does not have support for these media types.” This was in reference to the media type of “application/javascript” or “application/ecmascript.”
Well, this web designer is sticking to the old tried and true “text/javascript” for now. No use making more trouble in my designs.
More later…






I had the same problem. Spent an hour trying to work out what was wrong with my onload function before i finally noticed that application/javascript was been used instead of text/javascript.
I had only checked it in Firefox. so of course something was going to go wrong in IE!