Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Introducing JavaScript Where Does JavaScript Go?

Should you include the type of script being used in the <script> tag?

Hi,

I'm new to JavaScript and was just wondering if it's best practice to include the type attribute of text/javascript in the <script> tag? For example,

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

Or does it even really matter?

1 Answer

Abraham Juliot
Abraham Juliot
47,353 Points

It's not needed in HTML5

<!-- HTML4 and (x)HTML -->
<script type="text/javascript" src="javascript.js"></script>

<!-- HTML5 -->
<script src="javascript.js"></script>

Moderator Edit: Moved response from Comment Section to Answers and edited Markdown for HTML Syntax Highlighting