Does onclick() have to be coded in the HTML?

There shouldn’t be any scope issues that require that your script be in the head of the page. Anything that needs to be done to the page before it finishes loading should be done using server side scripting and not JavaScript. JavaScript should be used for the interactions that come after the page has loaded.

Also since the page should be usable without JavaScript, it shouldn’t hurt anything to put off loading the JavaScript until last thing in the page.

by inline scripting events I assume you mean running javascript code like calling functions or whatever before the </body> is reached and this I never do.

up till now I would say 99.99% of my javascript is called as part of window.onload and/or function calls from event handlers in elements and so thinking about what you said earlier I would expect most if not all my javascript files, that I normally link to in the <head> could be linked to just above the </body> in the future.

I’ll have a play with linking my js files just above the </body>