Reputation: 12227
Despite that the HTML4 standard states there is no default for the <script>
element, looks like browsers assume "text/javascript" by default. How safe is this assumption?
To Standards Nazis: I know this is something to raise an eyebrow upon, but I believe there is nothing wrong in exploiting some de facto standards for the sake of readability and succinctness (e.g. omitting quotes around simple attribute values, etc).
Upvotes: 0
Views: 120
Reputation: 14906
As of HTML5 then text/javascript
is the standard when no type
is specified.
Personally however, I'd be inclined to always specify type
- better safe than sorry!
Additionally, I'd always advise writing code under the assumption that someone else will have to support it. Do you think the next person along will thank you for your 'time-saving' solutions that make the code harder to follow? I very much doubt it ;)
Upvotes: 6
Reputation: 4562
From experience i know that it isn't safe to make this assumption.
However, the HTML5 standard does describe this standard value for the language attribute being "text/javascript".
Upvotes: 0
Reputation: 25858
HTML5 now doesn't require the mimetype to be declared in a script tag, as "text/javascript" is implied; so yes, I think it's safe to assume that this is the default.
Upvotes: 1