10
I was facing problems with the shipment of JS, mainly by IE8, and I came up with this doubt. I researched a lot, I ended up improving some things.
Currently, I upload all JS files at the bottom of the page, before the tag body
.
<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 case the funcoes.js
is where I call (or would like to call) all the functions of the site.
And that’s when the problems happen.
I have in it for example:
$(document).ready(function(){
validar();
});
$(window).scroll(function () {
...
});
$("#form_contato").validate();
$('.bxslider').bxSlider();
function validar(){
...
}
I don’t know if you have any order in calling these functions...
I don’t know, for example, when I have to use $(function(){...});
.
I always have to keep testing, and sometimes it happens in IE8 some function does not work, then the novel starts to change place (sometimes calling just below the scripts in body
between the tags script
resolve), then this function works, but another stops working, and then I’ll start doing tests again...
What could I be doing wrong?
Maybe this one question help. Does not specifically speak of ie8
– rray
Always put precedence in loading the
js
, following the above items that are required just after ... by the 3 references ofjs
of your example is not wrong to do so, but, it may be that you are calling item that has not yet been declared. Example: have there in your code bxSlider, Cade the reference of the same ??? Just remember that this is browser independent, if missing thejs
, mistakes are going to happen ...– user6026
This question should also help: http://answall.com/questions/8416/jquery-onload-x-jquery-ondomready
– bfavaretto