Which do you think is faster, have a ‘main.css’ style sheet then an additional style sheet for EACH section of the site, or having a ‘main.css’ style sheet and then having one additional style sheet for the entire rest of the site? The additional style sheet would hook elements via body IDs and classes and would require a longer selector. For example, #body-id .page-wrap.
The question boils down to: Does adding an additional selector for the section particular styles (10 – 20 unique elements) slow the site more than an additional HTTP request for a non-cached style sheet?
Which do you think is faster, have a ‘main.css’ style sheet then an additional
Share
No. The HTTP request will invariably be slower because of network latency. This is why you see pages load and render progressively — it’s because browsers are so good at computing and rendering styles that it happens while a page is being downloaded.
This is entirely up to you, though. If server-side performance is critical, it would be best to keep HTTP requests to a minimum, but don’t sacrifice maintainability for it. Forget about selector parsing or rendering performance, as that stuff is usually up to the browser to worry about.