jQuery的 - 它是坏的有多个$(文件)。就绪(函数(){}); [英] jQuery - is it bad to have multiple $(document).ready(function() {});

查看:87
本文介绍了jQuery的 - 它是坏的有多个$(文件)。就绪(函数(){});的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

难道不好有多个 $(文件)。就绪(函数(){}); 在你的网页?我有一个网站,我加载不同的东西在不同的时间。我火了里面的 $(文件)。就绪()的局部回传的功能,但我有大约4或5页上的一次。这是一个不好的做法?具体而言,它会导致任何性能问题?

Is it bad to have multiple $(document).ready(function() {}); on your page? I have a website where I load different things at different times. I fire off those partial postback functions inside $(document).ready() but i have about 4 or 5 on the page at once. Is this a bad practice? Specifically, will it cause any performance issues?

推荐答案

这样的回答不再是相关的。请参阅其他职位以下更多了最新的jQuery $。就绪()的影响。这篇文章是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-文档就绪

这篇关于jQuery的 - 它是坏的有多个$(文件)。就绪(函数(){});的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆