Improve Site Performance Increase Site Traffic Monitor Site Uptime Webmaster Resources NetMechanic Home Looking For Help? Partner Programs Privacy Policy Contact Us Press Room
NetMechanic Home LOGIN | HELP | ABOUT US | PRODUCTS | SITE MAP
NetMechanic Menu
Over 52 Million Web Pages Tested!     
 
Positioning tips.
search engine optimization story search.
Search for:


Your Email:

I would like to receive my newsletter in:
HTML format
Text format


Increase traffic.
Volume 8 (2005)
   September
   June
   April
   March
   January

Volume 7 (2004)
   November
   September
   July
   June
   May
   April
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 6 (2003)
   December
   November (Part 2)
   November
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part 2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 5 (2002)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 4 (2001)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part 2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 3 (2000)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June
   May
   April
   March
   February
   January

Volume 2 (1999)
   December
   November
   October
   September
   July
   June
   May
   April
   March
   February
   January

Volume 1 (1998)
   December
   November
   October
   September

 

CSS Tip:
Preloading Images With CSS

by Larisa Thomason,
Senior Web Analyst,
NetMechanic, Inc.

  
November 2003
Vol. 6, No. 18
 • Promotion Tip
 • Design Tip
 • CSS Tip
  

Web site visitors hate to wait, so many Web designers preload images to speed up page display. Although JavaScript is the most common way to preload images, it isn't your only option. Consider using the CSS DISPLAY property instead. It may be more reliable and it requires less complex code.

New Issues With JavaScript

Our June 2000 article discusses (in detail) how to preload images using JavaScript.

Preloading with JavaScript is a valuable technique! However, the main problem with using it is that browsers must be JavaScript-enabled and have JavaScript turned on. Without JavaScript, the images won't preload.

Your main problem used to be dealing with old browsers that didn't support JavaScript. Not many of those are still around, but now you face a new problem: some visitors deliberately turn off JavaScript because they don't want to deal with its more unsavory uses:

  • Pop-up ads
  • Pop-under ads
  • Changing the browser home page
  • Error messages from poorly-written code

Disabling JavaScript does protect users from the bad aspects, but it also deprives them (and you) of the benefits. Without JavaScript, the browser can't request the images needed on subsequent pages, so visitors wait longer for pages to load completely. That's wasted time for them and lost visitors for you.

Identify Slow Or Problem Pages

Fortunately, Cascading Style Sheets (CSS) offer you an easy and reliable option. Using the DISPLAY property, you can tell the browser to request an image, but NOT to display it on the page. The browser just requests the image from the server and caches it for future use.

Consider this scenario:

You run your own Web site that advertises your Poodle breeding and boarding service. Your home page contains a basic description of your business and the services you offer.

After studying your server log data, you find that most visitors enter your site via the home page. Their next stop is usually the page that contains pictures of the puppies you have for sale. After that page, they leave the site entirely.

Why? Maybe they don't like the looks of your puppies, but more likely, they just got bored waiting for the page to load!

Check your page download time first using HTML Toolbox. It alerts you to slow-loading pages, broken links, and HTML code errors. Then, use GIFBot to decrease image file size without reducing the display quality of images.

Finally, refer to your server logs to identify problem pages that turn visitors away.

Now, let's go back to the poodle example. The puppy page is full of images of adorable puppies, but maybe visitors don't wait to see all of them.

So let's use CSS to preload some of the puppy images on the home page.

Preloading With The DISPLAY Property

First, let's create a class with display set to none and add it to the HEAD section of the home page:

<style type="text/css">
.hiddenPic {display:none;}
</style>

Next, we'll add image tags for our puppy pictures to the bottom of the home page. Always place them at the bottom of the page! If the visitor is at the home page, you certainly want it to display as quickly as possible. Let the browser display the home page and its images before it starts trying to retrieve the images for the next page.

<img src="poodle-puppy-Clara.jpg" 
  alt="Clara at 8 weeks" title="Clara at 8 weeks" 
    height="350" width="350" class="hiddenPic">
<img src="poodle-puppy-Kenny.jpg"
  alt="Kenny at 10 weeks" title="Kenny at 10 weeks"
     height="350" width="350" class="hiddenPic">
<img src="poodle-puppy-Aiko.jpg" 
  alt="Aiko at 6 weeks" title="Aiko at 6 weeks"
     height="350" width="350" class="hiddenPic">

Note that we used the "hidden" class name for each image. Again, the browser will request the image files and save them locally, but will not display them on the home page as long as the DISPLAY property is set to none. Don't use that class for every image on your home page or none will display!

You also don't have to preload every image on the puppy page. If several attractive, important images load immediately, visitors have something to look at while they wait for the others to load. The important thing is to avoid making visitors stare at a blank page!

Keep Visitors' Interest With Content

It's hard to place too much emphasis on page download time. Up to 1/3 of visitors may leave pages that take more than 8 seconds to load! But once the page does load, make sure you give the visitors something valuable.

Visitors come to your site looking for information - and that means you need text on the page that's well-organized and easy to scan. Without good content, visitors won't stay at your home page (or whatever page contains the preloading code) long enough for the images to download and get saved in the browser cache!

Good information, attractive images, and fast-loading pages will keep visitors at your site and give you a chance to turn them into repeat customers.



Rate This Tip:
Not Useful Useful Very Useful   
 
NetMechanic Tools
HTML Toolbox
Browser Photo
Server Check
Search Engine Starter
Search Engine Tools
GIFBot
Newsletter
HTML Tutorial and Tips
Search Engine Tutorial
Accessibility Information
Browser Problem Tutorial

Company Info
Products
About Us
Contact
Advertise
Link To Us
Jobs
Privacy Policy
Partner Programs
Press Room
RSS Feed
Support
 



Powered by Overture!

 
     
 
   
 
     


Keynote Home
Copyright © 1996-2010,
Keynote NetMechanic
All rights reserved.