News for hackers. Stuff that matters.
Re:My favourite 3 lines of CSS by jraph on Tuesday February 21, 2023 @03:46AM (#34878488)
> avoid using * selector as much as possible in my CSS

So do I, I am somehow wired to think "* is going to be very bad for performance because now the rendering engine will need to apply this bunch of rules to any and every element on earth, which might not be only overkill, but which also might have undesirable side effect."

It might not really apply here but the feeling is present.

Re:My favourite 3 lines of CSS by rofrol on Tuesday February 21, 2023 @04:55AM (#34879039)
>The difference between fastest and slowest is only 43ms (0.043 seconds), and I saw around this difference between rendering the same css twice. I think it is best to go for whatever is most readable for you. Personally I find :first-child the most understandable at a glance.

https://www.reddit.com/r/web_design/comments/5u6e7b/comment/...

Re:My favourite 3 lines of CSS by majou on Tuesday February 21, 2023 @07:42AM (#34880455)
43ms is quite a slowdown isn't it? Handful of joules at least.
Re:My favourite 3 lines of CSS by jraph on Tuesday February 21, 2023 @08:18AM (#34880767)
Actually, the only two comparable / equivalent options exposed in this page related to this discussion, ul > * + * vs li:not(:first-child), are 50.8ms vs 40.9ms (respectively) for 10 page loads. The browser is not named, so I would guess Chrome. I'm not convinced the difference is not proven significant, we need more data points than that to know for sure, but it seems insignificant. So yes, readability should be the determining factor here.

Other browsers might see different results, especially Firefox which has a very fast / efficient CSS engine.

ps: a difference of 43 ms for one page load would be huge indeed. By comparison, a frame in a 30 fps video is 33 ms.

Re:My favourite 3 lines of CSS by xigoi on Tuesday February 21, 2023 @09:28AM (#34881535)
:not applies to almost every element, so it's not any better.
Re:My favourite 3 lines of CSS by jraph on Tuesday February 21, 2023 @04:27PM (#34887642)
very true indeed!