I saw the example on Yahoo, and they say the best place to put it is in the end of the body tag:
But on Google Code University video, they give an example, that the best way to put it is in the head, then call one of the function on that script:
They say the init() function contains code for attaching event listeners to HTML elements, because, if I only put it in the head, the event listeners won't be attached, because the browser haven't parse the HTML elements yet.
But I've recently found an example, that I can still put the script tag in the head tag, without calling the init function in the body tag. Instead, I could write
Can you suggest what's the best way to do this, and why? Or if you have a better technique, could you please explain that to me?