views:

88

answers:

3

In HTML5, you no longer need to include the type in a script tag when you are using JavaScript.

Are any common browsers (IE6+, Firefox 2+, Safari 3+, Opera 9+ or similar) going to break if the type is removed from all the <script> tags?

So, is changing the following:

<script type="text/javascript" src="/path/js.js"></script>
<script type="text/javascript">
...
</script>

to:

<script src="/path/js.js"></script>
<script>
...
</script>

... going to break anywhere?

+3  A: 
Sarfraz
+5  A: 

No it won't break any of the popular browsers, including the ones you mention. The <script> tag will work fine without the type attribute, because all popular browsers will default to JavaScript.

Quoting Douglas Crockford:

type="text/javascript"

This attribute is optional. Since Netscape 2, the default programming language in all browsers has been JavaScript. In XHTML, this attribute is required and unnecessary. In HTML, it is better to leave it out. The browser knows what to do.

Daniel Vassallo
+2  A: 

type was useful a lot of time ago where javascript was not standardized, and some differences were between versions of the same browser. You could use other languages like vbscript, but in the real world nobody has written website scripts for it. In these last years it is influential if you add it or remove.

Charlie