Saturday, April 13, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  4] [ 4]  / answers: 1 / hits: 76965  / 15 Years ago, fri, july 31, 2009, 12:00:00

I believe javascript can be anywhere (almost), but I almost always see it in between <head></head>. I am using jquery and wanted to know if it has to be in the head tags for some reason or if will break something if I move it. Thank you.



EDIT: Why is it almost always in the head tags?


More From » javascript

 Answers
53

JavaScript is executed wherever it is found in the document. If you place inline JavaScript in the body, it will be executed when the browser comes to it. If you're using $(document).ready(...) to execute things, then the positioning shouldn't matter. Otherwise, you may find corner cases where it matters. In general, it does not matter. Scripts end up in the head tag mostly out of tradition.


[#99019] Monday, July 27, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rossj

Total Points: 606
Total Questions: 100
Total Answers: 116

Location: Dominican Republic
Member since Sun, Sep 4, 2022
2 Years ago
rossj questions
Mon, Sep 13, 21, 00:00, 3 Years ago
Thu, Jun 17, 21, 00:00, 3 Years ago
Sun, Nov 22, 20, 00:00, 3 Years ago
Thu, Sep 3, 20, 00:00, 4 Years ago
Sun, Aug 2, 20, 00:00, 4 Years ago
;