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 trialAlex Hird
2,767 PointsWhen linking a HTML doc to external javascript file, can the <script src> tag be placed within the head or body tag.
When linking a HTML doc to external javascript file, can the <script src> tag be placed within the head or body tag. Thanks
Alex
2 Answers
Eric Park
1,063 PointsI believe it's recommended to be placed within the end of the body tag. The file is executed in order, so if your Javascript file references any HTML tags you want these tags to load before the Javascript file
Check out this link:
http://stackoverflow.com/questions/196702/where-to-place-javascript-in-a-html-file
johnnyesper
5,935 Pointsscript src="scripts.js" /body
Most common place. Right above last body tag.
Alex Hird
2,767 Pointsthanks
Alex Hird
2,767 PointsAlex Hird
2,767 PointsThanks for response, really helpful