Are the scripts which are kept inside the <head> tag are automatically loaded ??
I am pasting my code of snippet here :
function getXMLObject() //XML OBJECT
I know that if they are kept inside body , they need to be explicitly loaded using onload ? what about scripts inside the head tag ?
It does not make a difference to the script where they are kept - you can keep them in the head or body and it works the same way.
A script block consists of usually two components,
1 . Variable get loaded and function calls get executed without any additional call (like onload in the body).
2. Function definitions are not executed unless the function is called (you can call function from init() which itself is called onload of body!)
What you refer to when you mention that code in body is 'loaded ' using the onload method is a good practice that was followed (now the same is done using scriptless htlm - don't mix script and HTML) - it has nothing to do with where the script (body or head)is defined.