Posted By

nighthawk on 11/10/08


Tagged

javascript jquery webdev


Versions (?)

Who likes this?

39 people have marked this snippet as a favorite

benrudolph
sulfurito
jamesming
lfatr
jelm
dsntos
Leech
umang_nine
Hollow
oldmeaty
byjg
fackz
profpatsy
davidsi
masondixon
colingardom
sonnh
dinkan
athanassiadis
nwpratt
crispunk
creativeboulder
zayyarphone
dekehooper
tspitzr
aegony
mfigge
wearefreya
kgaddy
dayseye49
Moonglade21
wirenaught
chrisaiv
Snowalker
hxy202
rcraven
vggallego
aberdas
crvst


jQuery preloading images


 / Published in: JavaScript
 

URL: http://www.innovatingtomorrow.net/2008/04/30/preloading-content-jquery

Thanks to Matt Farina

Also see similar snippet for preloading arbitrary content, e.g. media in content received via AJAX.

  1. // preloading function of images
  2. jQuery.preloadImages = function()
  3. {
  4. for(var i = 0; i<arguments.length; i++)
  5. {
  6. jQuery("<img>").attr("src", arguments[i]);
  7. }
  8. };
  9.  
  10. // use like
  11. $.preloadImages("image1.gif", "/path/to/image2.png", "some/image3.jpg");

Report this snippet  

You need to login to post a comment.