views:

46

answers:

2

I'm profiling JavaScript using dynaTrace AJAX edition.

According to the tool's "Hot Spots", the following jQuery method is using the majority of execution time:

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

...it has over 700 invocations on my page.

What is this call and how can I optimize it?

I'm using jQuery version 1.4.2. The performance issues are primarily in IE6 and IE7.

+1  A: 

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. Instead it's using the querySelectorAll() if it exists, making the entire selector process much cheaper.

Nick Craver
My performance issues are in IE6 and IE7 (updated question to reflect this). Those browsers don't support querySelectorAll(). Thanks for the suggestion though.
frankadelic
A: 

Most likely, you should be optimizing the selectors you're passing into jQuery, not jQuery's selector engine itself. 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.

bcherry
Is the CLASS() method invoked whenever I am using ".classname" selectors?
frankadelic
jQuery doesn't have a method named `CLASS` within it, but I dynaTrace means the selector engine based on what you've described. Not sure where it got `CLASS` from.
bcherry