Web pages should load fast. Period. It’s irritating for any reason to wait on a computer. As a web developer, so many of the factors that go into page loading speed are outside of our control. However, some of the biggest ones are fixable with a minimal amount of work. The effort isn’t really justified for every page, but high traffic pages (like the university homepage) are definitely worth it.
Formatting for speed
As a programmer, I much prefer to maintain nicely formatted code. But when you are after speed, the whitespace has got to go. You can reduce the size of your page significantly. Smaller code size = less bandwidth used = faster load times = win for everyone but the programmer. Removing whitespace is effective on the HTML of the page, stylesheets and JavaScript.
Beyond whitespace
With JavaScript you can optimize even further. Tools such as Google’s Closure-Compiler can not only remove whitespace, but perform some pretty hefty optimizations on your code. For our redesign, Closure-Compiler reduced a 38KB file down to 14KB – and size was only part of the speed benefits it gave.
All zipped and ready
In today’s world, why would you send uncompressed resources? Processing power is cheap – it’s network speeds that still seem to limit us. Text files such as HTML, CSS and JavaScript can easily be compressed on the fly by almost any modern web server – as long as you have the processing power to spare. That 14KB JavaScript file actually gzips down to a measly 5.2KB. That brings our combined savings on that file alone up to nearly 87%!
Compression Resources
Zero is less than something
Of course downloading nothing is always faster. Usage stats show us that we have a high degree of returning visitors to our homepage. By setting some pretty aggressive cache headers, users only have to request new HTML. All of the images, stylesheets and scripts can be loaded from what they got on their last visit.
Cache headers are somewhat confusing and can have unintended side effects. Google has a great article on the relevant cache headers: http://code.google.com/speed/page-speed/docs/caching.html
Tools of the trade
Optimizing your site for loading speed can be a daunting task. There are a few tools that make this easier. My personal favorite is Google Page Speed (an addon for FireBug). In addition to a prioritized list of suggestions, several optimizations can be run within the tool itself such as image optmization and whitespace removal.
This is the second post in a series about the techniques used in the 2010 redesign of the Missouri State homepage. Other posts in the series:
- Personal and Course Websites to be Discontinued October 1 - June 21, 2024
- How catalog changes will affect your academic website - May 13, 2024
- Partial Site Outage 4-30-24 - April 30, 2024
- Modern Campus Calendar Details - April 2, 2024
- Calendar updates: Training available - March 20, 2024
- Updates: New Modern Campus Calendar - March 7, 2024
- Preview MSU’s new calendar system - January 22, 2024
- Recap: Hello Omni CMS, goodbye Web Press! - March 14, 2023
- Improve your Omni CMS skills at this free training - February 21, 2023
- Celebrate Global Accessibility Awareness Day (GAAD) on May 19 - May 16, 2022