In terms of execution time and resources employed, is it more convenient to load as much stuff as possible with 开发者_StackOverflow社区jQuery.ready()
or the bare essentials?
just use it as trigger for you init functions... Don't put all your code in it:
don't do:
$(function(){
var someFunction = function(){
$("a").click(function(event){
event.preventDefault();
});
};
someFunction();
});
do:
var someFunction = function(){
$("a").click(function(event){
event.preventDefault();
});
};
$(function(){
someFunction();
});
its more readable, and it simply makes no sense to put all your code in the ready function.
ps:
$(function(){})
===
$(document).ready()
精彩评论