Look at the browser's progress bar: it may be loading some counters and the document is not ready until they're loaded: this often happens when external resources are slow.
Try $(function(){ alert(...); }); just in case...
Check whether you have JS errors prior to this onload binding. Use Firefox's FireBug plugin to check it out.