- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Thu, 26 Apr 2012 10:29:47 -0700
- To: Sebastian Zartner <sebastianzartner@gmx.de>
- Cc: www-style@w3.org
On Thu, Apr 26, 2012 at 12:33 AM, Sebastian Zartner <sebastianzartner@gmx.de> wrote: >> For general CSS, though, you have to match *dynamically* - every time >> the document is changed, you must quickly find which selectors stop >> matching, and which new selectors start matching. This is *not* a >> trivial task, and it has to be done *quickly*, so that things like >> :hover feel responsive. Some features make this much harder, like >> :contains() and especially the subject selector. It might be possible >> to do dynamic matching quickly, but it's a non-trivial task. > > Sure, but if no one tries, we won't get any further. Also the use cases for :hover and :contains() are quite different. While reacting to mouse moves must be instant reacting to text changes does not forcibly. You're assuming here that the two pseudo-classes are used separately. They can show up in the same selector, you know. ^_^ >> And what's worse, the mere *presence* of one of these slow rules can >> potentially slow down matching for the entire page, even if it never >> actually matches anything. > > Yes, but that counts for all rules. Though of course by having slow rules you'll realize the decrease in page speed faster. Not really. Performance is often a black art; selector performance doubly so. The browser's Inspectors are finally starting to peel away the veil here, but it's still going to be something learned mostly through rumors and out-of-date tests, and most people won't care at all. You might be able to tell "hey, my page is slow", but figuring out *why* is much harder. Plus, a particular slow rule might not make a noticeable difference on the brand-new Macbook the author is using, but create a really choppy experience on an older desktop or a phone. It's like the difference between using "box-shadow: 2px 2px black;" and "box-shadow: 2px 2px 1px black;". It looks so small, but that little blur has a *huge* effect on page performance. It's one of the primary footguns on the web today, unfortunately, where pages run slow for no good reason just because an author put a little bit of blur in their shadows, and *their* computer was fast enough that they didn't notice the problem. ~TJ
Received on Thursday, 26 April 2012 17:30:43 UTC