Image Preloading Through CSS3 Caching
Have you ever wanted another option to preload images besides JavaScript? Try using the new "content" property to preload them at the bottom of your style sheet.
HTML:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="css/global.css" type="text/css" media="screen" />
<title>Image Preloading Example | 1</title>
</head>
<body>
<ul>
<li><a href="index.html">index1</a></li>
<li><a href="index2.html">index2</a></li>
<li><a href="index3.html">index3</a></li>
<li><a href="index4.html">index4</a></li>
<li><a href="index5.html">index5</a></li>
</ul>
<img src="images/img1.jpg" width="800" height="600" alt="keyboard" />
</body>
</html>
CSS:
ul{padding:0;*margin:0;}
ul li{display:inline;padding-left:10px;}
/*____ PRELOAD IMAGES ____*/
body:after{content:url(../images/img1.jpg) url(../images/img2.jpg) url(../images/img3.jpg) url(../images/img4.jpg) url(../images/img5.jpg);display:none;}

Explanation:
Basically what is going on is that instead of using some clunky JavaScript preloader you should use the new "content" property then modify it by ":after" pseudo-element then follow that with a "display:none;." Now someone with half a brain says that you can do the same trick by having containers for each image. I just want to say that my example is faster and simpler.
What I have done is to build a very simple example with obnoxiously large images to illustrate that the caching is working. Notice once you let the first page load, ever other page will take no load time because it has been cached. You can also see an example if you look at the bottom of my site’s css marked "/*____ PRELOAD IMAGES ____*/," see it here. Also, remember you need to place the preloading section at the bottom of your style sheet or it will cause a cascade failure in the loading of your site.
Note: This preloading trick only works on modern webkit browsers which is good becasue it will cover 90% of users. The webkit browsers that support it are FireFox 3.6, Safari 3, Chrome, Opera 9.62 and IE8. (IE8 uses a varient of webkit which is much like a cowboy monkey riding a dog in a circus) That means IE6 and IE7 are not covered, but you can use conditional comments and a lot of extra mark up if you want it to work in 6 & 7, but I honestly would not bother.
