Thread: JS fundamentals
View Single Post
Old 09-25-2012, 05:57 PM   PM User | #39
zygezund
New Coder

 
Join Date: Aug 2012
Posts: 17
Thanks: 10
Thanked 0 Times in 0 Posts
zygezund is an unknown quantity at this point
Quote:
Originally Posted by felgall View Post
Yes the declarations go at the top - both those declared via the JavaScript var statement AND ALL the HTML that the JavaScript code needs to reference - hence the actual JavaScript code ends up immediately before the </body> tag so that all the declarations it needs to reference go above it.
Thank you. I thought it was clear for everybody why scripts should be on the bottom of <BODY> not on the top or in the middle.

My question, actually, was, why not in the <HEAD>, where they could peacefully sleep, until called?
I think the <head> section was included into HTML mostly for that purpose (to keep executable code sleeping) otherwise I do not see any big reason, rather then decorative, to have this special section of HTML.

So I "refactor" my initial question.
Why to keep scripts in the <body>, not in the <head>?
__________________
Monkeys push buttons, humans push their brains
David Biedny, Photoshop Channel Chops (my first and still the best book on Photoshop. (May be it is the best one, because authors followed their own motto)
zygezund is offline   Reply With Quote