You are currently viewing the BOOK: Beginning JavaScript 4th Edition section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Is the "type" attribute important enough to basically always include in your opening <script> tag, or can it be optional these days. I've heard a couple different opinions on this - both strict and non-strict views actually. What's the best practice in majority of serious professional work environments?
If validation is important to you, and your documents are HTML 4.01 or XHTML, yes, type is required. If your document is HTML5, then no.
The type attribute was important a few years ago because without it, Internet Explorer had to guess what scripting language you used in a particular script element. Since IE7 or IE8, the type attribute defaults to text/javascript. So ultimately no, it's not required (unless validation is important to you).
Thank you for a typically clear explanation, and thank you for the very thoughtful sequence of instruction in your book, and the lucid prose that makes it such a terrific book!