load your css and html 20% faster with copy and paste skills

9 replies
A lot of people don't realize that the white space in your code takes up bandwidth. Each hit on the return key, and each tap on the space bar is information that needs to be down loaded to the browser.

One of the online html optimizers suggested that 20% of your bandwidth is saved. The last css sheet I optimized saved 37%. That one was quite large, for a forum, and had a lot of comments.

Css first. Copy your style (or whatever) .css and save a copy. This isn't just for back up. Most css optimizers strip out the comments.

Css first. To do it, just find your .css style sheet. A link to it will be toward the bottom of your head section on the html page. Copy the whole thing and save a copy. This isn't just for back up. Most css optimizers strip out the comments.

You can choose degrees of optimization with the css optimizers. For heavy traffic (yes!!) you can reduce the code to a single horizontal line. I have been doing this for a year without a problem. In fact I usually learn something when I do it. A css short hand that I missed, or 2 different declarations that were identical.

I don't want to recommend one. You can find plenty at Google.

This doesn't just save bandwidth, but also disk space and stress on the server. With Google taking page load time into account now, it might even help your ranking.

For html it is just a bit more tricky. I just tried it on a site lately and out of a dozen pages 2 were messed up. An Amazon affiliate banner 160 px wide by 600 high, was displayed as 468 wide by 60 high (!) Messy. Wrecked the layout.

The work around was to reduce everything up to the ad to a single line, and then everything after it. Just to be safe I do this with anything that has script and /script tags.

I've also had problems with IE 6 not showing a page when the head was in a single line.

Also I haven't seen an html optimizer that will reverse the process. (I've only used 2).

For an interesting example look at the source (Ctrl + U) of the Google search page. Just about a dozen lines, one of them going about 40 scrolls to the right. Also notice that it doesn't have an /body or /html tag, for the most interesting of reasons.

That's to save on bandwidth too! I read about that on one of their blogs. None of the browsers do anything with those tags. Guess the validators are just playing catch up.

With the amount of bandwidth they use just with utube, you might not expect this. It's a nice lesson for me. No point in wasting anything.
#20% #copy #css #faster #html #load #page not found #paste #skills
  • Profile picture of the author lovesecret
    I was not aware of this before, I have also noticed a lot of softwares that can do this job for , have you tried anyone?
    {{ DiscussionBoard.errors[3387079].message }}
  • Profile picture of the author andreasnrb
    If you are using WordPress check out W3 Total Cache. It can help you optimize a lot of of your site. No need to tinker yourself.
    {{ DiscussionBoard.errors[3387392].message }}
    • Profile picture of the author liamondrop
      Great tips overall. I was going to mention the Caching plugin, but andreasnrb beat me to it.

      As much as I love a well-commented css file, I love a quickly loading page more.
      {{ DiscussionBoard.errors[3387765].message }}
      • Profile picture of the author Lloyd Buchinski
        It was a genuine surprise to see this topic again. It just sank out of sight when I put it up over a year ago. So I added a few details and put up a web page about it, at optimize your code

        I posted it to reddit, got a couple of know it alls in a bad mood who down voted it enough to stop it from showing. It only takes 2 down votes to do that if they are the first 2 votes.

        Originally Posted by liamondrop View Post

        Great tips overall. I was going to mention the Caching plugin, but andreasnrb beat me to it.

        As much as I love a well-commented css file, I love a quickly loading page more.
        I do have pages where I need the comments. I keep the page, but just copy and paste it to the optimizer. The server gets the results from that, but the original page and all the comments stay with me.

        If I need to do something more with it, I just start with my saved version.
        Signature

        Do something spectacular; be fulfilled. Then you can be your own hero. Prem Rawat

        The KimW WSO

        {{ DiscussionBoard.errors[3405066].message }}
        • Profile picture of the author jonobl
          Thanks for the info. I never thought that spaces would make such a difference
          {{ DiscussionBoard.errors[3405446].message }}
  • Profile picture of the author Josh Anderson
    The Apache 2.0 mod deflate can lower your bandwidth by up to 75%!

    mod_deflate - Apache HTTP Server

    It works amazingly well.
    Signature
    {{ DiscussionBoard.errors[3387911].message }}
  • Profile picture of the author WillR
    From my experience with websites and coding, I don't believe saving a little whitespace in a CSS style sheet is the real problem. On a well written website a CSS style sheet is going to be tiny compared to most of the other scripts and images. You might save 20% but on a 10kb file is it really that important? Especially if your CSS sheets are hosted on an external server such as Amazon S3 - it bears no impact on your server whatsoever.

    Of more importance to improving page load speeds is optimizing the images on your page. You should always use a tool like GifBot to optimize your images before uploading them. It takes only a second and is free. You simply upload your image and it will then show you a whole lot of different versions of that same image and you can choose the one with the smallest file size that still has sufficient quality. You can save a ton of page load by optimizing your images - a lot more than you are likely to save by optimizing a tiny CSS style sheet.
    {{ DiscussionBoard.errors[3405719].message }}
    • Profile picture of the author Lloyd Buchinski
      Originally Posted by WillR View Post

      From my experience with websites and coding, I don't believe saving a little whitespace in a CSS style sheet is the real problem. On a well written website a CSS style sheet is going to be tiny compared to most of the other scripts and images. You might save 20% but on a 10kb file is it really that important? Especially if your CSS sheets are hosted on an external server such as Amazon S3 - it bears no impact on your server whatsoever.

      Of more importance to improving page load speeds is optimizing the images on your page. You should always use a tool like GifBot to optimize your images before uploading them. It takes only a second and is free. You simply upload your image and it will then show you a whole lot of different versions of that same image and you can choose the one with the smallest file size that still has sufficient quality. You can save a ton of page load by optimizing your images - a lot more than you are likely to save by optimizing a tiny CSS style sheet.
      So you don't think Expression Web should have the ability to do this built in? Or you don't think Google should do this?

      For anyone who does have EW, you can do this from your desktop. And a few days ago I looked at google's style sheet for my inbox. It was impressive. Just 2 lines of code vertically, but the bottom line scrolled to the right for what seemed to be at least 200 screen widths. I just held down the pointer in the scroll bar lane for about 5 seconds and it only moved about a tenth of the way across.

      I can't even remember why I looked at it, but I gave up at that point. It wasn't going to be easy to look through that.

      For anyone with the FF web developer's toolbar, you can just press ctrl + shift + e and you will see the css for any page, including the gmail inbox.

      I've enjoyed a few of your posts, but just want to try to adjust this one a bit. I'm not trying to claim there is any big advantage to doing this. The advantage is stated quite specifically, at about 20% of your file size. Of course a high resolution photo should be optimized for a site but most people know this. I have a cute story about my first try at that with Gimp, on the first photo of my first site.

      Code in general probably isn't the most important thing. I get sales pages provided for products that do look good, but the code is a mess. The person is obviously making more money than me and maybe just focusing on sales is a good thing.

      But I like things working well and if I can make a small improvement for the effort this takes I'll go for it. If you want a really surprising example of Google doing that, take a look at the source code for their search page at google.com. If you go to the end, it doesn't have an /body or /html tag. I happened to read one of their blog posts about that.

      The reason it doesn't is to save on bandwidth

      The post said that none of the browsers do anything with those tags anyway so there isn't much point having them. With all the bandwidth they use for video a person might not expect something like that. But it was an interesting lesson for me. If something is an improvement, go for it, small or large. Beats wasting time.

      Personally I do leave those tags on. I had a couple of pages that were easier to adapt to IE 6 with them in. At least it seemed that way.
      Signature

      Do something spectacular; be fulfilled. Then you can be your own hero. Prem Rawat

      The KimW WSO

      {{ DiscussionBoard.errors[3689451].message }}
    • Profile picture of the author Christian Little
      Originally Posted by WillR View Post

      From my experience with websites and coding, I don't believe saving a little whitespace in a CSS style sheet is the real problem. On a well written website a CSS style sheet is going to be tiny compared to most of the other scripts and images. You might save 20% but on a 10kb file is it really that important? Especially if your CSS sheets are hosted on an external server such as Amazon S3 - it bears no impact on your server whatsoever.
      You're looking at it wrong. Saying "it's such a tiny improvement that it doesn't affect anything" is looking at the small picture, when in reality you need to look at the big picture.

      Let's use your example - a 10kb CSS file that gets shrunk by 20% when optimized.

      Let's say you get 500 visitors to your site per day with 3 pageviews per visitor.

      There is a difference of 2kb in content that is loaded per pageview, so:

      500 visitors x 3 pages/visit x 2kb = 9000kb/day.

      That's 9 megabytes.

      Yeah it's not a huge amount, but it adds up, especially over time.

      Over the course of a year, that 9MB/day becomes 3.285GB/year.

      Huge number? Not really, but it adds up when there's 300 websites on the server doing the same thing.

      300 websites x 3.285GB/year = 985.5GB/year. That's almost a terrabyte of data transfer saved throughout the year. Now the numbers aren't looking so small are they?

      Now let's be realistic and look at a Wordpress site. Most themes these days use multiple CSS files and multiple JS files. Let's say 5 files each.

      Then let's assume 6 PHP files that makeup the theme coding.

      That's 11 files that can be compressed. Do the math.
      {{ DiscussionBoard.errors[3689547].message }}

Trending Topics