I was facing problems with loading JS, especially IE8, and I had this doubt. I researched a lot, I ended up improving some things.
Currently, I load all JS files at the bottom of the page, before the body
tag.
<body>
...
...
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="jquery.validate.min.js"></script>
<script type="text/javascript" src="funcoes.js"></script>
</body>
In the case of funcoes.js
is where I call (or would like to call) all functions of the site.
And that's where problems happen.
I have in it for example:
$(document).ready(function(){
validar();
});
$(window).scroll(function () {
...
});
$("#form_contato").validate();
$('.bxslider').bxSlider();
function validar(){
...
}
I do not know if you have any order in calling these functions ...
I do not know, for example, when I have to use $(function(){...});
.
I always have to be testing, and sometimes it happens that in IE8 some function does not work, hence the novel of moving places (sometimes calling just below the scripts in body
between the tags script
solves), then this function works, but another one stops working, and then I'll start testing again ...
What can I be doing wrong?