In html files, you probably can write:
<script type="aaa/bbb" src="xyz.js"></script> language=”javascript”
In JavaScript files (.js) it is just the raw JavaScript codes without specifying the type, is it assuming all types are “text/javascript”? What if you have typed like “aaa/bbb”?
Dojo is an example may require this.
Yes, in a JavaScript file you just write the code without any tags around it. It’s the tag that includes the file in the page that specifies the type. So you might have:
foo.js:
…which you include like this:
You can optionally specify the
typeon thescriptelement:…but in practice this is unnecessary for JavaScript, you’d only need it if you were referencing a file that wasn’t JavaScript (like VBScript on IE).
Note that the
languageattribute in your example was never part of any specification. Since HTML 4 (12 years ago), the correct way to indicate the language is via thetypeattribute.