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
-
Should I Use WooCommerce Tags & Attributes?
I'm helping an online furniture store search engine optimize a WooCommerce store and I'm trying to make sure our taxonomies make sense. I'd love any help you guys can give, but I'm particularly interested in determining whether we should use tags. Product attributes make sense to me, but I'm concerned to use tags because of the propensity for creating duplicate content. Thanks in advance for any help you guys are willing to give.
On-Page Optimization | | cbizzle0 -
Would it be inappropriate use of authorship mark-up for a directory profile?
If a business creates a profile in a directory and adds their Google+ page, and they add the domain/profile URL as a publisher they contribute to, is that a legit use? They are the author of the business profile, but it's not an article.
On-Page Optimization | | designquotes0 -
Should I put on a black hat and abuse Rich Snippet ?
What do people think about abusing rich snippets? I have a competitor who has started using the author tag on product pages. I guess this will be giving them an unfair advantage in the SERP. I had considered doing the same but was a bit worried about getting banned in the future. Should we go down the same path and is it likely that Google will eventually hit us with a ban?
On-Page Optimization | | DavidLenehan0 -
How about this "onpage overoptimisation" everybody is talking about? Are the on-page optimisation reports still to be used?
Are the on-page optimisation reports still to be used? If we do check all factors we risk penalization because of latest Panda update?
On-Page Optimization | | MugurCosminFrunzetti0 -
Is rel=canonical used only for duplicate content
Can the rel-canonical be used to tell the search engines which page is "preferred" when there are similar pages? For instance, I have an internal page that Google is showing on the first page of the SERPs that I would prefer the home page be ranked for. Both the home and internal page have been optimized for the same keyword. What is interesting is that the internal page has very few backlinks compared to the home page but Google seems to favor it since the keyword is in the URL. I am afraid a 301 will drop us from the first page of the SERPs.
On-Page Optimization | | surveygizmo0 -
Do you use <nofollow>and rel=nofollow?</nofollow>
I just read http://www.thoughtmechanics.com/does-nofollow-attribute-work-google-says-yes-studies-say-otherwise/ . Is it really better to avoid using nofollow for local links (from one site to itself)?
On-Page Optimization | | fleetway0 -
I have a direct question about file structure.
This question is about a new file structure and SEO friendly URL's. Does a file name make a difference? I have a direct question about file structure. Our old site was formated with a URL of http://rousechamberlin.com/about_us.aspx our new site is structured http://rousechamberlin.com/AboutUs/ no file no extension. As the SEO guy of the company and not the programmer my feeling is this is killing us. Does anybody have any thoughts on this?
On-Page Optimization | | HeadWebChef0 -
SEOMOZ suggested site optimzation change on 1 low level page
I asked this before, but did not really get an answer, so checking again. Really grateful for any help... My question is: Based on the PRO crawl Diagnostics – if we don’t make a recommended change on say 1 rather obscure page, does that just affect the SEO on that one page only, or does it potentially affect the SEO on all (more important) pages of the site? e.g. home page etc E.g. If we get a “Too many on page links” for a certain page that we don’t really want to rank for – does not fixing that particlaur page really affect the SEO for the site as a whole? Or just that 1 page (that I don't really care too much about) Hope someone is able to answer, thanks so much...
On-Page Optimization | | inhouseninja0