如何提高jQuery的性能 [英] How to increase performance of jQuery

查看:105
本文介绍了如何提高jQuery的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用jsp和jQuery编写的聊天应用程序。我已经为在某些URL中不断发布请求的线程使用了setTimeout方法。我的浏览器在一段时间后挂起,cpu利用率非常高。

i have an chat application written in jsp and jQuery. I have used the setTimeout method for threads who are continuously posting request in some URL. My browser is hanging after some time and cpu utilization is very high.

有没有办法提高JS的性能?

Is there any way to increase performance of JS?

推荐答案

检查一下:
http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx#tip1

它有一些非常好的建议,如:

It has some really good recommendations like:


  • 通过缓存将选择操作降至最低

  • 保持DOM操作至少

  • 尽可能使用ID而不是类

  • 为选择器提供上下文

  • Keep selection operations to a minimum by caching
  • Keep DOM manipulation to a minimum
  • Use IDs instead of classes wherever possible
  • Give your selectors a context

这篇关于如何提高jQuery的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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