Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Let's build a browser engine, Part 4: Style (limpet.net)
66 points by mbrubeck on Aug 23, 2014 | hide | past | favorite | 2 comments


CSS matching is one of the more resource-intensive parts of the computation the browsers do; the given implementation is very instructive for understanding the algorithm, but would be too slow for any nontrivial page. The total possible number of comparisons is basically {number of rules} * {number of elements}, which can be extremely high, and avoiding this is quite important.

I am reminded of how IE uses a single integer to identify each CSS rule: http://blogs.msdn.com/b/ieinternals/archive/2011/05/14/10164...


Interesting. So is that typically the reason why pages with large number of elements are so slow? I had always assumed it was the HTML elements themselves, but could the bottleneck here sometimes be the CSS matching of those elements?

Also, if I'm not mistaken, I believe that Servo (which the author of this post works on at Mozilla) is attempting some novel parallel CSS matching using Rust's support for parallelism/concurrency.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: