If you are reading this, please get modern browser.
skip to main content | skip to main navigation | skip to secondary content

Image Preloader

~ 2nd May 2005. · 16:54 CET · permanent link · printer friendly ~

When slicing down .PSDs to style the markup, CSS girls and guys usually start with a set of generic rules such as

* { margin: 0; padding: 0; }

Then they set a few additional rules:

p, ul, ol, dl { margin-bottom: 1em;  }

to make sure everything has some global default white space. At this point they usually style links and corresponding pseudo-classes (:hover, :focus and :visited). After ‘initialization’ of the CSS file, they probably dive into site specific styling. But hold on! Why not establishing generic content image preload notification while we are here?

Why We Would Do That?

Visitors browsing at slow Dial-up connections have to wait until large images load and they don’t have a clue something is missing — they see an empty block of space between two blocks of text. I know it confuses me sometimes. If we provide visual clue that something is happening with the web page (the image is loading and nothing hangs), they will rest assured that the particular image will show eventually.

Background Animation Behind the Content Image

We need only one simple line of CSS:

img { background: url(loading.gif) no-repeat 50% 50%; }

and a GIF animation. GIF is prefect, because it has a small file size and we don’t need anything fancy, just the visual clue.

Universal ‘Preloader’

If wanted to use this generic background image, there should be a certain level of customization. With a little as possible CSS tweaking (changing background color of the content image) we can reuse the same GIF. Here’s sample ‘preloader’. preloader sample This animation is transparent, so it’s fairly reusable. Right click and take it with you…

Shown example is nothing revolutionary, but it’s easy to implement and it’s usable interface detail. Take a look at the demo page.

6 Comments

  1. I like this idea. I have noticed that some browsers will indicate that they have finished loading the page’s content before the background images specified through the CSS have actually loaded. This way, there would be something to indicate that I should look for more images to load before I really start focusing on the site.

  2. I wonder if specifying a lowsrc on the img itself might not be more effective.

  3. I think that lowsrc wasn’t w3c recommended attribute, but if someone knows better, please let me know.

  4. What’s fascinating is that DOM Level 1 seems to include lowSrc as a valid property of an image object but you’re right in that I can find no mention of the lowsrc property in the spec. Also, Blooberry indicates that very few browsers actually support the non-spec. So, just ignore my suggestion. :D

  5. Yeah, I know a this … good solution anyway.

  6. cool little idea. it’ll fix a lot of missunderstandings in discussions with clients concerning loading speeds. It allways bother me, as this discussion is nowadays absolutely useless, but it seems to struck the clients mind. Thanks for this tool. Wolfram.

Sorry, the comment form is closed at this time, but if you have anything to say, please send me a message.

* Please keep in mind that this is a personal web site and it does not reflect the position or opinion of my respective employers, organizations or partners.

Typetester – compare screen type Supported by Veer.

What is this?

A web log of Marko Dugonjić, web professional from Croatia. Topics covered:

Translate this site

German, Spanish, Italian, French or Japanese (via).

See you there!

Feel like buying a book?

Try with maratz.com aStore

Worth visiting

top of the page | skip to main content | skip to main navigation | skip to secondary content