jQuery add image to browser cache

Submitted by:Jhon Smith

Date added:31 March, 2012

Category:jQuery

jQuery example code to add image to browser cache

Tags: add image

Code Snippet:

(function($,D,W) {

var JQUERY4U = {};

JQUERY4U.UTIL = {

images:
{
loadingImage: '<img class="loading" src="images/loading.gif" alt="loading" />',
ajaxImage: '<img class="msg-loading" src="images/ajax-loader.gif" alt="" />',
savingImage: '<img class="loading" src="images/saving.gif" alt="saving" />'
},

preloadImages: function()
{
$('body').append('<div id="img-cache" style="display:none/>');
$.each(JQUERY4U.UTIL.images, function(i,v)
{
$('#img-cache').append(v);
});
}

}

$(D).ready(function($) {
JQUERY4U.UTIL.preloadImages(); //preload images in browser cache
});

})(jQuery,document,window);
 
 

Comments