gpt4 book ai didi

jQuery - 有多个 $(document).ready(function() {}); 是不是很糟糕?

转载 作者:行者123 更新时间:2023-12-03 21:27:48 24 4
gpt4 key购买 nike

页面上有多个 $(document).ready(function() {}); 是否不好?我有一个网站,我在不同的时间加载不同的东西。我在 $(document).ready() 中关闭了那些部分回发函数,但页面上同时有大约 4 或 5 个回发函数。这是一个不好的做法吗?具体来说,它会导致任何性能问题吗?

最佳答案

此答案不再相关。请参阅下面的其他帖子了解更多最新的 jQuery $.ready() 影响。这篇文章已有 3 年多了。

参见:http://jsperf.com/docready/11

The answer is no! You can litter them as much as you want (note the word litter). They just become a queue of events that are called when the ready event is triggered.

http://www.learningjquery.com/2006/09/multiple-document-ready

关于jQuery - 有多个 $(document).ready(function() {}); 是不是很糟糕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1148241/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com