使用两个或更多$(document).ready ..会影响性能吗? [英] Does it affect performance to use two or more $(document).ready.. ?

查看:177
本文介绍了使用两个或更多$(document).ready ..会影响性能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个网站项目。该项目的负责人告诉我,保留两个或更多 $(文件).ready 是不对的。这会影响性能吗?我更喜欢保留多个 $(document).ready 因为我有很多jquery代码,这是划分代码块的好方法。

I am working on a website project. The person in charge of the project tells me that it's not right to keep two or more $(document).ready .Does it affect performance? I prefer to keep multiple $(document).ready because I have lots jquery code, and it's a good way to divide blocks of code.

推荐答案

这是一个额外的函数调用,所以它当然会影响性能。

It is an extra function call, so of course it affects performance.

它不会以任何重大方式影响它。它可能甚至不会以任何可测量的方式影响它(假设典型计算机上的所有其他变量都会影响浏览器中的JS性能)。

It won't affect it in any significant way. It probably won't even affect it in any measurable way (given all the other variables on the typical computer that impact JS performance in a browser).

这篇关于使用两个或更多$(document).ready ..会影响性能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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