user3475724
user3475724

Reputation:

How faster is using id instead of class for single jQuery selectors?

I often use .class to select a single html element. However, this is not correct. I've read somewhere that using #id is the optimal approach when using jQuery. How much faster is using #id instead of .class when trying to select a single element?

Upvotes: 1

Views: 404

Answers (1)

Kokizzu
Kokizzu

Reputation: 26828

According to this link that taken from ewwink's answer, yes selecting by ID are faster than single class in any common browser.

jsperf

Upvotes: 4

Related Questions