Skip to content

Instantly share code, notes, and snippets.

@piyonishi
Created July 23, 2013 04:15
Show Gist options
  • Save piyonishi/6059817 to your computer and use it in GitHub Desktop.
Save piyonishi/6059817 to your computer and use it in GitHub Desktop.
// 1つの場合
function preloader() {
heavyImage = new Image();
heavyImage.src = "sample.jpg";
}
// 複数ある場合
function preloader() {
// counter
var i = 0;
// create object
imageObj = new Image();
// set image list
images = [];
images[0] = "sample1.jpg"
images[1] = "sample2.jpg"
images[2] = "sample3.jpg"
images[3] = "sample4.jpg"
// start preloading
for(i=0; i<images.length; i++) {
imageObj.src = images[i];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment