top | item 29793691

(no title)

Kavelach | 4 years ago

Note that the owl selector is pretty slow when it comes to being processed by browsers. If you use it sparingly, it shouldn't be so bad, but leave it all over the place, and you'll see the impact

discuss

order

y4mi|4 years ago

Ha, when I first learned about it I remade a pretty interesting navigation menu purely with :not :checked :focused :hover etc, so pure html and css, thinking it would be more performant then my previous JS version.

Its performance was not just measurably worse, it was obvious as soon as I opened the revision on my phone.

Lesson learned: it's important to think twice before using most pseudo selectors

Kavelach|4 years ago

> I remade a pretty interesting navigation menu purely with :not :checked :focused :hover etc, so pure html and css, thinking it would be more performant then my previous JS version.

That sounds so cool! Do you have a version somewhere that I can take a look at? I always like fiddling with clever CSS, even if it is too clever for its own sake, as you managed to find out

And keep in mind, that pseudo selectors are not created equal. Things like :checked or :focused usually don't have that much of a performance impact

the_other|4 years ago

> owl selector is pretty slow when it comes to being processed by browsers

I'm sure this hasn't been relevant for about 15 years. CSS rendering is _fast_.

Kavelach|4 years ago

As I mentioned above - one or two clauses like that won't hurt performance, but I have seen situations, when bad CSS (a lot of *'s, too long selectors, a lot of dead and unused clauses) actually had a measurable impact on websites' performance.

This especially comes into play, if you deal with a lot of nested HTML elements or when you modify the site's HTML a lot.

goldenkey|4 years ago

Is there a place to see css benchmarks on modern browsers, like jsperf used to be for JS?

It seems like > *+*, *:not(first-child), *:nth-child(1+n) and *:last-child { ...revert... } are all equivalent. I would be curious to know which is most efficient.

edoceo|4 years ago

How can one even test the performance of these selector? I've been have a few pages that feel slow, and have some exotic selectors, but I've no clue what tools to uses. And searches for CSS performance tell me lame things like: minimize and use a CDN. I have the XY problem.

mst|4 years ago

Try adding 'browser' and/or 'layout' as keywords for your searches - that seems to surface stuff about the relevant sort of performance.

(this semi helpful advice brought to you by mst's complete lack of front-end chops meaning concrete help will have to come from somebody else ;)