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
-
Do non-canonical pages need to worry about things like Alt Text, H1 tags, etc?
Just wanted to confirm, if we have multiple similar pages, with all of their canonicals pointing towards the prime page, does it impact SEO rankings at all if the non-canonical pages were missing alt text from their images, or shared duplicate or multiple H1 tags? Basic SEO page construction stuff? I know some will hurt user CTR but wanted to make sure that SEO crawlers don't care about them even if indexed.
On-Page Optimization | | SimonZM2 -
What is the best tag to use for your Logo ?
Hi, I'm wondering what is the best tag to use on your logo. We're currently using h1 and i want to scrap that ASAP.
On-Page Optimization | | Alex.harvey.Cortex0 -
Should title contain the term Top 10?
One of my clients' run a hyperlocal marketplace (have different pages for each city) to hire music teachers. Should the title be "Hire Violin Teachers, Tutors from Boston"? or "Top 10 Violin Teachers of Boston". I prefer former title as it has 2 keywords - "violin teachers", "violin tutors" than latter. But my client argues that "Top 10" has a strong affinity to attract users that would increase CTR. Am I right? or Is he right? and Why?
On-Page Optimization | | Avin1230 -
Which speed test to use?
Hi so I have a very easy question I think. I am too new to seo stuff to know better, but which speed test site is the best? I have a construction website. My issue is I am getting mixed results. Pingdom is showing <dl> <dt>Load time</dt> <dd>1.18s</dd> </dl> <dl> <dt>Requests</dt> <dd>22</dd> </dl> <dl class="last"> <dt>Perf. grade</dt> <dd>94/100</dd> <dd>Gt metrix is showing 98/87 with a 2.13 load time.</dd> <dd>And it varies from when I do it.</dd> <dd>So which do I go off of?</dd> <dd>With pingdom, I feel pretty good.</dd> <dd>With gtmetrix I feel like maybe I could improve.</dd> <dd>I ask because I have been looking into a cdn, but because its like learning a foreign language to me, I do not want to go there unless I have too.</dd> <dd>Thank you for any advice on which speed test to view as most accurate</dd> <dd>Chris</dd> </dl>
On-Page Optimization | | asbchris0 -
When You Add a Robots.txt file to a website to block certain URLs, do they disappear from Google's index?
I have seen several websites recently that have have far too many webpages indexed by Google, because for each blog post they publish, Google might index the following: www.mywebsite.com/blog/title-of-post www.mywebsite.com/blog/tag/tag1 www.mywebsite.com/blog/tag/tag2 www.mywebsite.com/blog/category/categoryA etc My question is: if you add a robots.txt file that tells Google NOT to index pages in the "tag" and "category" folder, does that mean that the previously indexed pages will eventually disappear from Google's index? Or does it just mean that newly created pages won't get added to the index? Or does it mean nothing at all? thanks for any insight!
On-Page Optimization | | williammarlow0 -
Using a lightbox - possible duplicate content issues
Redesigning website in Wordpress and going to use the following lightbox plug-in http://www.pedrolamas.pt/projectos/jquery-lightbox/ Naming the original images that appear on screen as say 'sweets.jpg'
On-Page Optimization | | Jon-C
and the bigger version of the images as 'sweets-large.jpg' Alt text wise I would give both versions of the images slightly different descriptions. Do you think there would be any duplicate content issues with this? Anything I should do differently? I'm very wary of doing anything that Google is likely to think is naughty, so want to stay on their good side! Cheers
T0 -
Good idea to use hidden text for SEO purposes due to picky clients not allowing additional content?
I do SEO for eCommerce websites both in-house and for clients. A few of our clients want increased rankings but are not willing to allow us to make the changes internally to help make that happen. One of which is adding content to the webpages since 90% of them have very little to none. I have a couple clients that are extremely picky about what can be seen on their eCommerce website. They have the site setup the way they want it but it is not SEO friendly in the slightest. The pages (including homepage) have little to no content, and the only things they want changed are things visitors CANNOT see on the webpages (META, ALT Tags etc). The tactic i am wanting to use is often used by spammers but i have a legitimate reason to use this and wanted to know if this would be a good idea. They are wanting to target fairly competitive keywords but are unwilling to allow any on-page changes to add any information and keywords to help with rankings. I was thinking about adding text behind images or hide the text in whatever ways to prevent the end user from viewing it (except for the search engines). My idea was simply to add a paragraph or two of content for the search engines purely to help in ranking because they have a lot of pages that have zero content except for product image and title listings. Is this tactic recommended or does anyone have any other ideas for these type of situations. Thanks,
On-Page Optimization | | VITALBGS
Stephen0 -
CMS program that have indexing problems
I am working on optimizing a website that was built with an CMS program. I searched for what pages are indexed on Google using "site:url" command. For some reason none of the pages are indexed on Google. What is the best way to index these web pages?
On-Page Optimization | | webdynamics0