开发者

How should I combine $(document).ready statements?

开发者 https://www.devze.com 2023-01-16 20:29 出处:网络
Is it appropriate to combine all functions that wouldn\'t conflict into one $(document).ready(function) {

Is it appropriate to combine all functions that wouldn't conflict into one

$(document).ready(function) {
});

or

$(function() {
});

call to sa开发者_如何学编程ve a couple lines?


To jQuery, it makes no difference whether to use one big .ready() handler, or call it several times. Internally, they all got merged together anyway or will get fired instantly when the DOM is ready already.

In my opinion, it's not a good practice to have more than one .ready() handler. Its like asking for confusion.

0

精彩评论

暂无评论...
验证码 换一张
取 消