Possible Duplicate:
Where is the best place to put <script> tags in HTML markup?
Where should I put javascript code?
<-- Here?
</body>
<-- Here?
</html>
<-- Here?
I’ve always used above </body> just wanted to know if this was “the best”
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If the JavaScript needs to be ready to go before the entire page loads, you put it between
<head></head>. If the JavaScript needs to be available right before the user encounters something on the page, you can put it prior to the element in the<body></body>(although people hardly do that for code readability). If the JavaScript just does some enhancements or provides tracking information (it’s not a necessity), you can put it right before</body>.