Is it better to put all your CSS in 1 file or is it no problem to use 10 files or more like on most frameworks?
-
Is it better to put all your CSS in 1 file or is it no problem to use 10 files or more like on most frameworks?
-
Thanks a lot for this usefull info, it helped me understand this better.
-
Hi,
From a code management point of view - as Peter says it's very common practice to split your CSS into different files as they are then much easier to manage and maintain. You can use a tool like Yahoo's YUI compressor to minify - as Bradley says - and aggregate (merge) these files.
From a web performance point of view, less files does not always mean better performance. Web browsers used to only download up to 2 files per domain, but now it's pretty standard for them to support 6 or more. See a browser breakdown for Max Connections and Connections per hostname here: http://www.browserscope.org/?category=network&v=top. I wouldn't recommend trying to split across 6 files, but you might find that if you have one massive CSS file it will download quicker when split up.
There is another disadvantage to having a single, CSS file in that you're not making the most of web browser caching. Every time you change any CSS, all users will have to download the entire file again. Again this may not be a problem for you, but something to bear in mind.
My advice would be to point Google Pagespeed at your website's key pages and act on as much as the feedback as possible: https://developers.google.com/speed/pagespeed/. It is a fantastic resource and presents its findings very clearly.
George
@methodicalweb -
That's what I was thinking too.. Currently, most of my frameworks have 10 CSS files, which means you have 10 server requests. Page speed as in my eyes a very important factor, therefore this question...
-
You could split them up based on where they are needed but that would become complicated. The advantage of splitting CSS on a large site is really to better organise the functionality of the CSS, e.g. system.css.
Peter
-
For a production environment, I would suggest having one minified CSS file. This will reduce file size (minifying) and server requests (1 file as opposed to 10). This will help reduce page load time.
Of course, on your staging environment, or in an archive of the website, it would be best to have your stylesheets broken down into an easier to manage system. That might mean multiple CSS files, it might not - it's up to you to manage.
-
Thanks for your answer!
It makes sense, because on large sites you will need different styling on different type of pages? So when you would put it all in 1 file, al this CSS would be loaded on ALL pages, while it's only needed on some particular?
Or what's the advantage here?
-
It really depends on how big your site is and how complex your CSS. On a small site or if it has minimal CSS one is perfectly adequate. On a larger site with lots of pages and CSS it makes sense to break down the the CSS around their function.Peter
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
What tools or tactics do you use to identify which ranking factors Google is weighting for your industry or keyword?
Google ranking factors are increasingly more complex and less universal. Google is emphasizing different ranking factors for different scenarios. What tools are available that can help identify which ranking factors Google may be weighting for a given query or industry? For example, are there any tools that provide correlative analysis of Google's rankings for a given keyword?
On-Page Optimization | | AdamThompson0 -
Advantage of using LocalBusiness rich snippets?
I am working on a website that has company profile pages. What are the advantages of using LocalBusiness rich snippets for profiles?
On-Page Optimization | | calf0 -
Product Landing page- Key Words used too often.
Hi There to everyone. I'm very new at SEO so I appreciate all the help I can get! Question: on my e-commerce website, one heading is "USB KEYS", then when you click on that, you get a page full of products with the word "USB KEYS" on the title, such as "4gig black USB KEY".. So then I do the MOZ Page grader and get a low score because on the product landing page it thinks I've used the word "USB KEYS" too much, like 72 times,.. But I have to use it- Cause it has to be in the product title! Is this ok!? thanks
On-Page Optimization | | cowhidesdirect0 -
URL Domain Used in Meta Description
Today I was asked if using a domain url in your meta description can have a negative impact on your website. This description includes a list of the homepage url, but directs visitors to a different internal page of the website. My concern fell with directing visitors to a different page of the site, but promoting the homepage in the description/snippet. With Penguin 2.1 release on the 4th, I'm very cautious of my links/urls. What are your thoughts behind this? What are the possible, if any negative impacts this could have on a site? This URL does have a brand name as so the Title.
On-Page Optimization | | flcity150 -
High Volume Duplicate Title and Content Errors: Scale of 1-10 How bad is this?
I have 15k pages and 1.5K have duplicate title and content errors. the reason is I have a ring parent page with child pages for each of the size variations. On a scale of 1-10 how big an issue is this and does it need fixing?
On-Page Optimization | | Tippman0 -
Meta tag "revisit after" - useful?
Hi everybody, I've rarely seen the "revisit after" meta tag during the last 1,5 years. As some of my current client websites are still using it and I'm not sure, if it's still usefull/has any effect, I'd like to hear from the community. Any advices/hints/experiences with the tag? Thanks in advance and cheers from Germany Sven
On-Page Optimization | | targi420 -
Using a more relevant brand title for blog
I'm a newbee here so I appologize in advance for asking a question that might already be aswered ( i looked I promise). The question is this, I've been fiddling with the title tags and came upon the need to make a decision about separating our blog brand to be more specific to it's content. We're a moving company, our primary website talks about services and is branded with our name (%page_name% | 2 Brothers Moving & Delivery Portland Oregon), our blog is a work in progress "Moving Guide" (%post_title% | Portland Moving Guide). Should I stick with the standard brand name on the blog or call it something keyword specific like above? As a side question what do you all think about my titles in the first place? In case you'd like to take a look: www.2brothersmoving.net www.2brothersmoving.net/blog
On-Page Optimization | | r1200gsa0 -
Problem with fresh content on homepage
On my site my homepage acts as sort of a landing page that is geared towards getting the customer sign up (almost like a PPC landing page aside from a few navigation options...about, blog, contact and the legal docs in the footer). My blog is geared towards other businesses in the industry and the like minded tech people. My problem:
On-Page Optimization | | JasonJackson
From a user perspective I don't feel that blog snippets would add anything useful to the homepage. However, I feel like I fresh content would help my SEO endeavors. Suggestions? Note:
Should be mentioned that all my social stuff is deeply integrated into my /blog so importing tweets, for example, is out of the question.0