Tips and Tricks About Computers, Web Development, Linux, the Internet and the Like
Optimizing CSS selectors for load time; #home is faster than #menu li a#home
I was trying to figure out how to cut rendering time with smarter CSS. In my quest, I came across a plugin by google for Firebug called Page Speed which not only answered my question in the ‘Use efficient CSS selectors’ section (* #header #menu a:hover — Tag key with 2 descendant selectors and hover pseudo selector) but provided more details on the subject on the Page Speed Documentation.
“Descendant selectors are inefficient because, for each element that matches the key, the browser must also traverse up the DOM tree, evaluating every ancestor element until it finds a match or reaches the root element. The less specific the key, the greater the number of nodes that need to be evaluated.”
So, #home is faster than #menu li a#home; at least in Mozilla’s case. More on this here
| Print article | This entry was posted by Tyler Mulligan on June 27, 2009 at 12:45 pm, and is filed under DOM, HTML, css. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 8 months ago
Interesting… I wonder what kind of implications this would have on a larger scale with a WordPress blog/blog network.