SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Jun 8, 2007, 15:43 #1
- Join Date
- Jul 2005
- Posts
- 7
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
JS in the head ... or body ... why not?
Hi all,
I've got a script I want to start using on my site, it's the son of suckerfish menu system. There is a bit of JS required, and altho it doesn't specify that it go in the "head" section I assume it must as most do ...
But my deal is this - I have a common menu include for the 100+ pages - I stuck the JS at the top of the include (include contains only html - no head tags) and the script works fine. This saves me having to insert the JS into all of those files. Yes, I'm a bit lazy at times.
My question is this: Why is most JS inserted between the head tags? I see that it will work in the body tag - so what is the advantage of the head tag placement? Should I bite the bullet and do the insertions - or will it be okay as is?
Thanks!
Dodge
-
Jun 8, 2007, 16:18 #2
The head part of the page is loaded first, so any JS that should be used later in the body is included there. Likewise, even the JS in body part is completely valid as long as it included before used.
If it works for you, means you did everything ok.Saul
-
Jun 9, 2007, 03:33 #3
- Join Date
- Jul 2005
- Posts
- 7
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Great! Thanks so much
Dodge
Bookmarks