frankadelic
frankadelic

Reputation: 20803

How to optimize CLASS function in jquery

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.

Upvotes: 2

Views: 106

Answers (2)

bcherry
bcherry

Reputation: 7238

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.

Upvotes: 0

Nick Craver
Nick Craver

Reputation: 630559

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.

Upvotes: 1

Related Questions