How We Got DynDNS.com To Load Faster And How You Can Learn From It

02.15.2011 By

We’re focused on engineering excellence here at Dyn and are routinely brainstorming ways to continue to improve user experience. As attendees of the Velocity Conference and notorious nitpickers of page load time, we were proud of how fast DynDNS.com loaded…but knew we could do even better.

Why care about load times? Page speed has an impact on sales and conversions and is a big part of the user experience. I dug through our front-end files, cleaning and optimizing our site until we’d sliced our page load time in half!

Here are some tips on how to make some major improvements to your site’s speed:

Do the first big pass at cleaning CSS files

What it did for us:

  • Homepage stylesheet: 41.94% file size improvement
  • IE-specific stylesheets: 92.11% file size improvement
  • Main stylesheet: 11% file size improvement
  • Other high-traffic pages: 12.9% file size improvement

By removing unused CSS (I like the Dust Me Selectors plugin for Firefox combined with grep to see what’s no longer being used) and reorganizing the file to combine similar style declarations, I was able to clean up the bulk of the files.

Look for:

  • unused styles
  • opportunities to condense/combine styles
  • inefficient selectors
  • opportunities to make sprites in the next step
  • unnecessary semicolons, spaces, shortcodes and leading zeros (it’s easy to find and replace for these)
  • messy HTML markup – clean up the HTML to create more efficient CSS
  • patterns in styles – gzip likes to see patterns, so reorganize styles near each other that have similar strings

A lot of the IE styles were either no longer used or I knew how to clean them up in the main stylesheet. It was worth moving the short list of remaining styles to be embedded in the header so we could eliminate the call to the CSS file.

I then merged the home page CSS styles into the main CSS file, which yielded a 4.94% size improvement, and brought it down to only one CSS call!

Right before I finished, I passed the file through CSS Compressor, which caught any minification opportunities I didn’t. CSS Compressor doesn’t play nice with CSS3 styles and a few other things, so I don’t use the option to export their code, but it gives you line numbers of things to change. Super helpful!

Clean up images

What it did for us:

  • 40% improvement in image files’ size
  • 85.7% improvement in image files’ calls

I love sprites. I created two types of sprites using the template’s images: one that is intended to repeat (and is 1px wide), and one that is used for no-repeat backgrounds. I created these for the homepage styles and the main styles.

I created the sprites using Photoshop and then exported them for the web. The sprites with transparency I used PNG-8 and limited the number of colors to just those that I needed, or I used PNG-24 if I needed alpha transparency. When I don’t need transparency, I export as JPG and test the quality scale to see how high it should be before I see noticeable file quality decline. I then run every image through ImageOptim, which compresses them further (and does it really well – especially PNGs!) before using them on the site.

Create a style guide and normalize your colors

What it did for us:

  • Additional 6% CSS file size improvement

DynDNS.comWe use a lot of golden yellows and deep grays on DynDNS.com, and I wanted to make them consistent across the site. I created a style guide that details which hexadecimal code to use when you want a bold yellow, light yellow, red warning message, green “changed” message, etc.

I also went through to find the most-used shades of gray; finding them helped determine the only gray hex codes we should use on the site and how they should be used (#aaa should be used for disabled text and borders; #eee can be used as a background, etc.). I went through the CSS and updated it to only use the colors in the style guide; this also helped condense a lot of elements that now use the same styles.

Combine JS files into one

What it did for us:

  • Went from three Javascript file calls to one!

Though combining our Javascript files into one file didn’t save us any file size, it did reduce three calls to files down to just one. Be careful as you combine them to make sure you keep their original loading order, and test away! Combining the files will help save round trips to request the file and receive a response over the network.

Create new subdomain to serve CSS and JS

Serving CSS and JS files through a different subdomain will allow your browser to retrieve them at the same time it gets your markup (except for, unfortunately, IE). We also put all of our static files on a separate subdomain to avoid cookies being transferred with each request.

Results

Original New Improvement
CSS 11.8K (gzipped) 7.2K (gzipped) 39%
Images 121.5K 63.85K 47.4%
Requests 22 9 59%
Page Speed Grade 95% 99% 4.2%
Time to fully load 3.550s 1.569s 55.8%

That’s less than half the original page load time!

  • http://twitter.com/Ryohara Ryan O’Hara

    Sick!

    • http://twitter.com/laraswanson Lara Swanson

      Thanks dude! Halving the page load time was awesome.

      • http://twitter.com/Ryohara Ryan O’Hara

        I’m very impressed…almost intimidated haha

  • http://twitter.com/mypigsfly Julie Parenteau

    Great post Lara! Exciting stuff!

    • http://twitter.com/laraswanson Lara Swanson

      Thanks, Julie! Now for Dyn.com… :)

      • http://twitter.com/mypigsfly Julie Parenteau

        TOTALLY!

  • Whogan4

    Wow, this is really impressive, I wish more web developers paid attention to these details.

  • http://www.5o9inc.com/ Peter Cranstone

    Glad to see you’re compressing the content (I’m one of the inventors of mod_gzip). In a few weeks time we’ll be releasing a new mobile browser than can analyze HTTP traffic in real time. Here’s a sample for you. DynDNS.com on Android (Sprint) with real time GEO data and your web site: http://www.5o9mm.com/har/viewer/v.pl?path=accounts/5o9/android-02-15-2011-20-07-28-GMT-www-dyndns-com.har

    It’s impressive.

    Cheers,

    Peter
    5o9 Inc.

  • Itelltruths

    Slick, slick, slick!

  • Pingback: How to speed up your page load time - Lara Swanson

  • http://bluesmoon.info Philip Tellis

    Have you considered taking advantage of parallel script downloads in modern browsers (Firefox, Safari, Chrome and IE8+ but not Opera)?

    • http://twitter.com/laraswanson Lara Swanson

      Hi Philip! Great suggestion. Currently, the majority of users are on IE. Our next steps will be improving JS processing, but right now we’re focused on making pages load faster for everyone. I think we’ll be figuring out specific pages where we need to load jQuery, and removing it for all the rest.

  • http://twitter.com/ndorfin Shaun O’Connell

    Great stuff Lara!
    If you don’t have to support IE6, then you could start using base64-encoded images in your CSS (for standards-compliant browsers) and an MHTML file for IE7, removing the need for sprites.

  • Joey

    Percentages are misleading. Report them to the total page and then it’s clear : the most important gain comes from the images. Cleaning up the html + css can take a lot of time, but a quite easy work on the images “only” (well ok you prably will have to modify some html and css) is the most important.
    Not if you have to optimize a news site, of course, but if you have a lot of pages and if Google make brings you people on many different pages, you should consider focus on the images only and wait the next redesign to clear everything up.

    • http://www.dyndns.com Alex Sergeyev

      Joey, bytes saved on images is only half of the success. Browsers spend time on downloading multiple CSS files and processing Javascript more then they do on downloading images and showing them up. Inefficient rules in CSS are also big deal, they really slow rendering and it’s hard to compare oranges to apples (network transfer speed to rendering speed in this case).

      • http://zeroload.net Zeroload (Vincent Voyer)

        Optimizing images was not the biggest improvement I guess.

        Optimizing CSS & JS (reduce file size, combine) is a lot more efficient at speeding up a website. Mainly because the browser will show a blank page untill all CSS+JS of the head section are finished downloading. (this is what you call rendeting speed)

  • http://iamdanielmarino.com Daniel Marino

    Excellent job! I know first hand that trimming fat off of a website can be a major headache. Here are some other things I noticed.

    Looks like you have a lot of JavaScript loading in the head section of your site – you can probably move most if not all of those scripts to the bottom of the page, before the closing body tag. That will help make sure content loads before the browser has to download extra scripts.

    I know WordPress and other CMSs like to add a lot of unnecessary classes in the markup – you might be able to clean some of that up by tweaking your settings in the CMS.

    If you serve your markup as HTML5, you can get rid of unnecessary element attributes. For instance: on script tags you could remove type=”text/javascript” – doesn’t seem like much but it can add up quickly.

    One last thing – I would recommend moving all inline styles, and javascript events (like onmouseout, onmouseover, etc…) into existing css and js files if you can (I realize some of that is done by the CMS). Again, the less markup you have to load, the faster the user will get the content – and it helps with organization too.

    Again, great job!

    • http://twitter.com/laraswanson Lara Swanson

      Thanks, Daniel! We didn’t clean up the site that this blog post is on, but rather http://www.dyndns.com. Perhaps we’ll do the same steps to this site as well soon! :)

      • http://iamdanielmarino.com Daniel Marino

        Ah yes, you did say it was dyndns.com – I can’t keep track of all the “dyn”-related domain names anymore :P

  • Pingback: La veille du week-end (dix-huitième) | LoïcG

  • eric

    Dust me is a pretty cool tool but I prefer using http://Unused-CSS.com This one allows you to download the clean CSS file directly.

  • Pingback: 22 not-so-short links about web performance — Web Performance Today