[英]How to increase performance of jQuery
i have an chat application written in jsp and jQuery. 我有一个用jsp和jQuery编写的聊天应用程序。 I have used the setTimeout method for threads who are continuously posting request in some URL.
我已将setTimeout方法用于在某些URL中连续发布请求的线程。 My browser is hanging after some time and cpu utilization is very high.
我的浏览器在一段时间后挂起,CPU使用率很高。
Is there any way to increase performance of JS? 有什么办法可以提高JS的性能?
Check this one: http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx#tip1 检查这一点: http : //www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx#tip1
It has some really good recommendations like: 它有一些非常好的建议,例如:
Well i run trough this before here is what i did (by the way this has nothing to do with jquery) : 好吧,我在这之前做过了(这与jquery无关):
try {
window.clearInterval(x);
} catch(e) {
// do nothing
}
x = setInterval(Update, 1000);
in your case you should clearTimeout :) 在您的情况下,您应该clearTimeout :)
try this : 尝试这个 :
refresh() { $.post("./chatServlet", { message: "hxci", name: $("#author").val(), event: "AUTOROOMMESSAGE", roomname: $("#select").val() }, function(xml) { $("#msg").empty(); addMessages(xml); }); try { window.clearInterval(x);} catch(e) { } x = setInterval(refresh, 3000); }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.