JS placement: Beginning or at the end of the file?

Discussion in 'JavaScript' started by enchance, May 15, 2008.

  1. #1
    Which is the safer bet, to place your JS (including external JS) within the <head></head> tags or at the very end of your <body></body> tag? Or better yet, is it more efficient to simply use the code below:
    
    
    <head>
    <script type="text/javascript">
    
    document.onload = function(){
         //execute all js functions
    }
    </script>
    </head>
    <body>
    </body>
    
    Code (markup):
    Which do you use?
     
    enchance, May 15, 2008 IP