Do HTML5 Script tag need type="javascript"?

Html

Html Problem Overview


> Possible Duplicate:
> Do you need text/javascript specified in your <script> tags?

Do in HTML5, the <script> tag need attribute type="text/javascript"?
I mean isn't it obvious if the <script> tag will be contains javascript?

Html Solutions


Solution 1 - Html

No, it's now officially useless.

> The type attribute gives the language of the script or format of the > data. If the attribute is present, its value must be a valid MIME > type. The charset parameter must not be specified. The default, which > is used if the attribute is absent, is "text/javascript".

Simply do

<script src=yourpath.js></script>

(yes, you can omit the quotes too)

Note that you don't have to worry about pre-HTML5 browsers, all of them always considered JavaScript to be the default script language.

Solution 2 - Html

From the spec:

> If the language is not that described by "text/javascript", then the type attribute must be present

And:

> The default, which is used if the attribute is absent, is "text/javascript".

Conversely, that means that if your src attribute is for a file that is valid JavaScript, it is not needed.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGusDeCooLView Question on Stackoverflow
Solution 1 - HtmlDenys SéguretView Answer on Stackoverflow
Solution 2 - HtmlOdedView Answer on Stackoverflow