I have a simple question, and there is an answer but I want to know which is better.
When loading scripts through the <script>
tag is it better to assign the script in header or body?
A book I am reading, "html5 game development by example", says to put the scripts right before the ending </body>
tag, so that the entire page loads first (because, if a script does not load it will render the page useless).
Where as, if I use, an onLoad
argument with an additional loading check for jQuery load (jQuery website says not to use onLoad with jQuery, so this is my work around), it should all be readily available? Without, the page getting stuck?
Is there a better, standardised method, that will keep my sanity in check?
<body onload="init()">
<!-- HTML code here -->
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script>
function init() {
$( document ).ready(function() {
jQueryReady();
});
};
function jQueryReady(){
// $( "p" ).text( "The DOM is now loaded and can be manipulated." );
// call remaining functions...
};
</script>