Skip to content
Better HN
Top
New
Best
Ask
Show
Jobs
Search
⌘K
0 points
goatlover
3y ago
0 comments
Share
Use ids when JS needs to reference unique elements. Use classes for styling and accessing groups.
undefined | Better HN
0 comments
default
newest
oldest
isleyaardvark
3y ago
JS can do just as well with unique classnames, which avoids issues with ids like those given in the article.
sgc
3y ago
I always presumed this would usually entail a performance hit, since you are accessing something that is not defined as unique.
isleyaardvark
3y ago
It's an infinitesimal performance decrease, and it avoids a lot of other issues.
j
/
k
navigate · click thread line to collapse