jquery - preloading images with javascript -


i'm making site in i'm using jquery change background images on page. there quite few images substituted through course of site.

by declaring variables @ beginning of script, preload images , therefore allow faster substitution of images? or, if many images (like 50), slow things down? or variables use memory?

are there issues see plan, or there better way?

var img1 = "url('images/wackawacka.jpg') repeat";  var img2 = "url('images/wabbaawacka.jpg') repeat";  var img3  etc... 

if you're declaring variables strings, javascript won't preload images.

take @ article how preload images javascript: http://www.techrepublic.com/article/preloading-and-the-javascript-image-object/5214317

using method when document loaded, can load images users' cache after page loads, when switch, they'll accessible.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -