jQuery进行图片预先加载
/** **将图片加载到内存中,在页面任何位置引用的时候,直接从缓存中读取,提升用户的体验,提高网站的流畅度。** **/ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>预加载图片</title> <script type="text/javascript" src="jquery/jquery-1.9.1.js"></script> <script type="text/javascript"> (function($) { var cache = []; $.preLoadImages = function() { var args_len = arguments.length; for (var i = args_len; i--;) { var cacheImage = document.createElement('img'); cacheImage.src = arguments[i]; cache.push(cacheImage); } } })(jQuery) $.preLoadImages('images/sample1.jpg','images/sample2.jpg','images/sample3.jpg'); </script> </head> <body> </body> </html>
全部教程http://each.sinaapp.com/angular/index.html