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
-
Use of subfolders for my casino directory
Been trying to find an answer to this for some time, so I hope someone can lend me a hand.. I've started building out my casino website Nerdybet, which will list regulated gaming vendors within each US state. A part of the idea is to create a high level web directory of legal betting sites. Now, say I want to list all legal casinos within a specific US state. What's the most search engine friendly way to build out the hierarchy? To clarify, this will be the main casino directory page: https://www.nerdybet.com/gambling-sites-directory Based on that, I can now pick either: a) Nerdybet.com/gambling-sites-directory/stateX
On-Page Optimization | | llevy
b)Nerdybet.com/stateX Which method would you say is best? And why so? Thank you.1 -
Wordpress category url problem.
I have set up wordpress categories but the permalinks are showing as www.mydomain.com/?cat=12 as opposed to the category name. The child categories though work fine and show as www.mydomain.com/category/chidcatgegory I've obviously got my permalink settings wrong somewhere. How do I fix this?
On-Page Optimization | | SamCUK0 -
Im seeing a Dot after the / on a new project, never seen this before, any issues using this format ?
Hi Ive got a new project and seeing a dot after the forward slash something ive never seen before what does it mean ? Are there any seo issues regarding it, is it bad practice or fine to proceed using that format ? Example below; www.domain.co.uk/**.**cool-new-product Thanks Dan
On-Page Optimization | | Dan-Lawrence0 -
Robots file include sitemap
Hello, I see that google, facebook and moz... have robots.txt include sitemap at the footer.
On-Page Optimization | | JohnHuynh
Eg: http://www.google.com.vn/robots.txt Sitemap: http://www.google.com/sitemaps_webmasters.xml
Sitemap: http://www.google.com/ventures/sitemap_ventures.xml Should I include my sitemap file (sitemap.xml) at the footer of robots.txt and why should do this? Thanks,0 -
Using phrases like 'NO 1' or 'Best' int he title tag
Hi All, Quick question - is it illegal, against any rule etc to use phrases such as 'The No 1 rest of the title tag | Brand Name' on a site?
On-Page Optimization | | Webrevolve0 -
To use or not to use: Keywords with locations
Hello there. I work for a marketing agency that manages SEO campaigns for a variety of small businesses in South Florida. Let's say we have a client that sells cheap shoes at their store location. Obviously, we want to show up in Google rankings for search terms like "cheap shoes south florida" or "cheap shoes miami." Now, my question is, when optimizing a website's content for various keywords, is it really necessary to include keywords with the location (which are often awkward for both reading and writing purposes)? Ideally, I'd prefer to have text that always reads as naturally as possible. Text like this is just an eyesore: Welcome to ExampleSite.com, home of the best cheap shoes Florida. We offer all kinds of cheap shoes Boca Raton. Your whole family doesn't have enough fingers and toes to count how many cheap shoes West Palm Beach we have in stock! Contact us to ask about our cheap shoes Miami discounts today! Olé!" What say you? Is there a way to work around ugly SEO text like this while still effectively ranking for GEO terms? Thanks!
On-Page Optimization | | BBEXNinja0 -
Which redirect to use when redirecting to https page from http page
I have one form under https which is redirected from the regular http page. this site was not made by me and I am trying to understand if the way it was redirected using 302 redirect is a problem Thanks
On-Page Optimization | | ciznerguy0 -
Is it better to include the secondary keyword or site name in a title tag?
When I add a site name to my title tag with long-tailed primary and secondary keywords the title tag is longer than 70 characters. I need to include all three parts, so what should I do? At 70 characters the site name is usually partially cut off. I do not want to get penalized by Google, but I need to include the site name to have consistency. I am using the format Primary Keyword-Secondary Keyword | Site name
On-Page Optimization | | lwilkins0