可以加入jQuery的听众减慢浏览器的性能? [英] can adding jQuery listeners slow down browser performance?

查看:106
本文介绍了可以加入jQuery的听众减慢浏览器的性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序,通过Ajax带来了回应,并创建在每次刷新5-20新的jQuery点击听众。 IE和Mozilla浏览器似乎放缓和使用。可这显著减慢浏览器的性能。可以监听被释放?

I have application that brings response via Ajax and creates 5-20 new jQuery click listeners on each refresh. Both IE and mozilla browsers seem to be slowing down with usage. Can this slow down browser performance significantly. Can listeners be "released"?

推荐答案

监听器设置使用 .bind()当元素被删除 被释放或 .unbind() 版。这些设置使用 .live() 持续到你叫 .die() 或元素他们必然要被删除(这可能是某处DOM如果指定,否则它会默认为DOM根 - .live()的工作方式是不绑定所以元素的目标元素可以被删除/更换/升级和事件监听器仍绑定)。

Listeners set using .bind() are released when the element is removed or .unbind()ed. Those set using .live() persist until you call .die() or the element they are bound to is removed (which may be somewhere in the DOM if you specify, otherwise it'll default to the DOM root - .live() works by not binding to the target element so the element can be removed/replaced/updated and the event listeners are still bound).

5-20听众听起来数太多 - 考虑约束较少处理,如果可能的较旧的浏览器将在pressure远比较新的更快的破解

5-20 listeners sounds a few too many - consider binding less handlers if possible as older browsers will crack under the pressure far quicker than newer ones.

这篇关于可以加入jQuery的听众减慢浏览器的性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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