Here are some key strategies that will help you to optimize various types of code:
• Keep your code clean! – Eliminate unnecessary comments and superflous markup. Focus on clean, well-written code and you will have a strong foundation for optimizing your pages.
• Use sprites for images - Put simply, sprites are multiple images consolidated into a single image. By strategically placing different images in a single image file, we decrease latency in visual display while also reducing the overall number of HTTP requests. Sprites are commonly used together with CSS to create stunning and effective rollover effects, background imagery, and more. • Include your stylesheets at the top of your pages – When including external stylesheets in your pages, be sure and include them at the top of the page in the <head> section. This will enable browsers to render your pages progressively, which makes them appear to load much faster than they would otherwise.
• Validate your code! - One of the best ways to ensure that you are adhering to the principles of modern web design and web standards is to check your code with an online validator. After checking your page, the validator will return a report telling you either that your code has passed with flying colors, failed miserably, or anything in-between. If there are problems with your code, the validator will explain each issue and provide suggestions for fixing them.
There are many different validators available depending on code type, however, the W3C (World Wide Web Consortium) provides just about everything you need right under one roof. Here are some URLs for two of their free code-validation services: