简体   繁体   English

如何在jQuery中优化CLASS函数

[英]How to optimize CLASS function in jquery

I'm profiling JavaScript using dynaTrace AJAX edition. 我正在使用dynaTrace AJAX版本分析JavaScript。

According to the tool's "Hot Spots", the following jQuery method is using the majority of execution time: 根据该工具的“热点”,以下jQuery方法占用了大部分执行时间:

CLASS(*, *, undefined, *, undefined, false): false

...it has over 700 invocations on my page. ...在我的页面上有700多次调用。

What is this call and how can I optimize it? 这是什么电话,我该如何对其进行优化?

I'm using jQuery version 1.4.2. 我正在使用jQuery 1.4.2版。 The performance issues are primarily in IE6 and IE7. 性能问题主要集中在IE6和IE7中。

If possible, upgrade to jQuery 1.4.3 which has major improvements in this area for newer browsers...by optimize, I mean this doesn't even get called most of the time. 如果可能的话,升级到jQuery 1.4.3 ,这对于较新的浏览器来说在该领域有重大改进……通过优化,我的意思是大多数时间甚至都不会调用它。 Instead it's using the querySelectorAll() if it exists , making the entire selector process much cheaper. 相反,它使用querySelectorAll()如果它存在 ,使得整个过程选择便宜得多

Most likely, you should be optimizing the selectors you're passing into jQuery, not jQuery's selector engine itself. 最有可能的,你应该优化你传递到jQuery的,不是jQuery的选择引擎本身的选择 Perhaps you could identify the most common selectors you use, or find a way to identify the slowest. 也许您可以确定您使用的最常见的选择器,或者找到一种方法来确定最慢的选择器。 We may be able to help optimize those if you provide them. 如果您提供它们,我们也许可以帮助优化它们。

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

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