or ", "text": "\r\n<p>Do you need a type attribute at all? If you're using HTML5, no. Otherwise, yes. HTML 4.01 and XHTML 1.0 specifies the <code>type</code> attribute as required while HTML5 has it as optional, defaulting to <code>text/javascript</code>. HTML5 is now widely implemented, so if you use the HTML5 doctype, <code><script>...</script></code> is valid and a good choice. </p>\n\n<p>As to what should go in the type attribute, the MIME type <code>application/javascript</code> registered in 2006 is intended to replace <code>text/javascript</code> and is supported by current versions of all the major browsers (including Internet Explorer 9). A quote from the relevant RFC:</p>\n\n<blockquote>\n <p>This document thus defines text/javascript and text/ecmascript but marks them as "obsolete". Use of experimental and unregistered media types, as listed in part above, is discouraged. The media types,</p>\n\n<pre class="prettyprint"><code> * application/javascript\n * application/ecmascript\n</code></pre>\n \n <p>which are also defined in this document, are intended for common use and should be used instead.</p>\n</blockquote>\n\n<p>However, IE up to and including version 8 doesn't execute script inside a <code><script></code> element with a <code>type</code> attribute of either <code>application/javascript</code> or <code>application/ecmascript</code>, so if you need to support old IE, you're stuck with <code>text/javascript</code>.</p>\n <br>\r\n<p>Both will work but xhtml standard requires you to specify the <code>type</code> too:</p>\n<pre class="prettyprint"><code><script type="text/javascript">..</script> \n\n<!ELEMENT SCRIPT - - %Script; -- script statements -->\n<!ATTLIST SCRIPT\n charset %Charset; #IMPLIED -- char encoding of linked resource --\n type %ContentType; #REQUIRED -- content type of script language --\n src %URI; #IMPLIED -- URI for an external script --\n defer (defer) #IMPLIED -- UA may defer execution of script --\n >\n</code></pre>\n<hr>\n<blockquote>\n<p>type = content-type [CI]\nThis attribute specifies the scripting language of the element's\ncontents and overrides the default\nscripting language. The scripting\nlanguage is specified as a content\ntype (e.g., "text/javascript").\n<strong>Authors must supply a value for this\nattribute. There is no default value\nfor this attribute.</strong></p>\n</blockquote>\n<p>Notices the emphasis above.</p>\n<p>http://www.w3.org/TR/html4/interact/scripts.html</p>\n<p><strong>Note:</strong> As of HTML5, the <code>type</code> attribute is not required and is default.</p>\n <br>\r\n<p>You need to use <code><script type="text/javascript"> </script></code> unless you're using html5. In that case you are encouraged to prefer <code><script> ... </script></code> (because type attribute is specified by default to that value)</p>\n <br>\r\n<p>This is all that is needed:</p>\n\n<pre class="prettyprint"><code><!doctype html>\n<script src="/path.js"></script>\n</code></pre>\n <br>\r\n<p><code><script type="text/javascript"></script></code> because its the right way and compatible with all browsers</p>\n ", "answerCount": 0, "upvoteCount": 618, "dateCreated": "1970-01-01 00:00:00", "dateModified": "1970-01-01 00:00:00", "author": { "type": "Person", "name": "Admin" } } }