简体   繁体   English

jQuery优化

[英]jQuery Optimizations

I've just come to the end of a large development project. 我刚刚结束了一个大型开发项目。 We were on a tight timeline, so a lot of optimization was "deferred". 我们的时间紧迫,所以很多优化都是“推迟”的。 Now that we met our deadline, we're going back and trying to optimize things. 既然我们已经达到了最后期限,我们就会回去尝试优化。

My questions is this: What are some of the most important things you look for when optimizing jQuery web sites. 我的问题是:在优化jQuery网站时,您需要了解哪些最重要的内容。 Alternately I'd love to hear of sites/lists that have particularly good advise for optimizing jQuery. 或者,我很想听到有关优化jQuery的特别好建议的网站/列表。

I've already read a few articles, http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx was an especially good read. 我已经阅读了一些文章, http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx是一篇特别好的读物。

@aepheus, here is another site for reference: www.artzstudio.com/2009 @aepheus,这是另一个网站供参考: www.artzstudio.com/2009

Check out #8 on Eliminate Query waste. 查看关于消除查询浪费的#8。 hth 心连心

mostly i look at selectors that repeat themselfs.. most of the times these can be saved into a variable and used over and over, for example: 主要是我看看重复自己的选择器..大多数时候这些可以保存到变量中并反复使用,例如:

$('.some_class').doSomthing();
$('.some_class').doSomethingElse();

can be turned into: 可以变成:

selectedItems = $('.some_class');
selectedItems.doSomething(); selectedItems.doSomethingElse();

this way the selector goes over the DOM once... then you can continue to use the variable as a jquery object thanks to the fact that every jquery method returns the jquery object. 这样选择器遍历DOM一次...然后你可以继续使用变量作为jquery对象,因为每个jquery方法返回jquery对象。

Just one tip out of many out there... 只有一个提示出了很多...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM