Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
97
rated 0 times [  104] [ 7]  / answers: 1 / hits: 16966  / 13 Years ago, mon, january 30, 2012, 12:00:00

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


More From » html

 Answers
23

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>.


[#87726] Sunday, January 29, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
iyannae

Total Points: 147
Total Questions: 88
Total Answers: 120

Location: Japan
Member since Sat, Jun 6, 2020
4 Years ago
;