3 ms·
Use ids when JS needs to reference unique elements. Use classes for styling and accessing groups.
by goatlover 4y ago
Use ids when JS needs to reference unique elements. Use classes for styling and accessing groups.
- isleyaardvark 4y agoJS can do just as well with unique classnames, which avoids issues with ids like those given in the article.
- sgc 4y agoI always presumed this would usually entail a performance hit, since you are accessing something that is not defined as unique.
- isleyaardvark 4y agoIt's an infinitesimal performance decrease, and it avoids a lot of other issues.