10 Quick Tips to Make CSS Load Faster

By 18-05-2013   BloggingTutorials

How can you make your CSS files load faster and quickly. Cascading stylesheets are an important component of your site design and it is essential your CSS files download fast and showcase your superb design element before other site components load. But as we continue to redesign websites, CSS bloat and poor CSS practices makes us forget the  importance of quick CSS delivery to visitors and need to increase site speed.

Faster CSS Download

fast cssSo here some quick tips to make your CSS load faster.

  1. External stylesheets – Always avoid inline CSS in the html code to style individual elements, because it loads with each page load. Whereas external stylesheets get cached by browsers and do not need to reload everytime a visitor continues to browse your site. Call style.css in HEAD tags of your html like this
    <link rel="stylesheet" href="http://domain.com/style.css" type="text/css" />
  2. Single CSS file – Lesser the number of CSS requests the better. Always choose to load a single CSS file only on each page.
  3. First Item to Load – Insert CSS as the first line in code after HEAD tags in your html. This ensures your CSS starts loading the moment the page loading starts.
  4. Small CSS files – the smaller the CSS file, the faster it will load and give design to your site. Use design elements only when needed. CSS3 allows you to add lots of fancy stuff like transitions, gradients etc. – but do you really need to style every element.
  5. Efficient CSS selectors – Learn CSS which enables you to join CSS codes into much smaller lines. For example
    margin-top: 0px; margin-bottom: 0px; margin-left: 2px; margin-right:2px;
    can be written as
    margin: 0 2px;
  6. Compress CSS files – Minify and compress the CSS code, again to reduce CSS file size so that it loads as fast as possible. While many plugins can do this, but it increases server load. Remove unnecessary white-space and CSS comments. We do online CSS Compression using YUI Compressor manually.
    compressed css
  7. Remove unused CSS code – We use GTmetrix to identify unused CSS and remove CSS bloat easily. Why load unused CSS when it is not required.
  8. Use a CDN – Content Delivery networks ensure your CSS is cached across the world and accessed as quickly as possible from the nearest local server for a superfast response. We use MaxCDN and simply drop the compressed CSS file via FTP.
  9. Avoid versions – Try to keep the CSS file url clean. Adding multiple query parameters with ? to highlight CSS file versions or add server time to force CSS refresh makes CSS caching difficult.For example
    <link rel="stylesheet" href="http://domain.com/style.css?1368887361">
  10. Learn CSS3 – it is the latest version of CSS and makes styling even more efficient. Harness the power of CSS the right way.

Try these fast CSS tips and make your site load faster.

40 comments on “10 Quick Tips to Make CSS Load Faster

  1. Rohan Mod says:

    my other blog has page size of 190 which is not good from SEO point of view.but the blog is hosted on blogger platform.how can i move all my css ? and is there any other website which allows such redirecting.please mention.

  2. Brad Dalton says:

    Yeah great tips.

    You could also use managed hosting which takes care of all this as well.

    My home page loads in 2/10 of a second if its wasn’t for the Facebook box in my sidebar.

    • P. Chandra says:

      Facebook scripts do take a lot of time. Implementing mod_pagespeed also can do a lot of CSS optimization automatically.

  3. Catalin says:

    Sass-scss compass will be an answer for a lot of your problems. One note: if your css file is lower than 30-40k you can dump te content in your html file. I saw test where iti performs better. Google does it. Also facebook widgets do it.

  4. Carter Davies says:

    Fabulous article. I have to thank you for mentioning GT Metrix in your article. I’ve tried several review tools to optimize my site and GT Metrix is a surprisingly good one. I can identify elements that has been slowing down the site in just a few seconds. Again, thank you for the insight.

  5. Vincent Armstead says:

    Css in the website is important as it provides a better look and feel to your website. But sometimes Css causes problems which ultimately result in high loading time to your website to open. so the tips mentioned in the post will surely help.

  6. Debopam Banerjee says:

    Css is extremely important….. It gives a nice feeling and look to a blog….. Thanks for this share…..

  7. Siddharth Solanki says:

    hello, thank you for the awesome post it helped me a lot and please keep sharing the awesome posts :)

  8. Ankit Sharma says:

    It is imported to compress white space in your codes.

  9. jhonmarshal says:

    Great post.I like it so much and i will apply those tricks in future for my website

  10. SHIV says:

    Thanks for the great tips. I never new that these thing are also affecting the CSS loading. Keep Tipsing !!!

Leave a Reply

Your email address will not be published. Required fields are marked *

*