Javascript is a very powerful "addon" tool, I don't think developers should call it anything other than that. The garnish on your steak, if you will. Now, I don't 100% of the time practice what I preach (but there is generally a good reason for it, rather than oversight).
I am once again going to recommend the
prototype library, you find that after working with a js framework/library things become much less daunting and it's far easier to just "do" something than re-write half a page of javascript which probably won't be reusable.
So, rather than using <body onload="..."> like many people would be used to, we'll simply put into place an observer.
Event.observe(window, 'load', init, false);Not very hard at all, we have setup a new "observer" which will wait for the page to load, and then call the function "init" which is where the code will lie for execution once the page has fully loaded.
Our init function can be anything really.
<script type="text/javascript">function init(){ alert('Just Testing!');}Event.observe(window, 'load', init, false);
</script>
Put that (along with the prototype library of course) in your head tag somewhere, and see how it works. It's a much more elegant way of doing things, and allows you to very easily queue events.
#1 Jeroen Mulder says:
Lately I've started using one of the many objects available that implement DOMContentLoaded in a cross-browser way. (though I'm sure Prototype supports that as well)
The one I use is Robert Nyman's ELO: http://www.robertnyman.com/2006/10/03/elo-encapsulated-load-object-the-ultimate-way-to-handle-window-load-events/
It's just that I'm not a fan of large libraries. I rather use individual objects to solve my individual needs.