1 //functions that define a preloaded picture list (with parameters)2Jquery.preloadimages =function(){3 //Traverse a picture4 for(vari = 0; i<arguments.length; i++){5JQuery (", Arguments[i]);6 }7 }8 //You can use the Preload function like this9$.preloadimages ("Images/logo.png", "Images/logo-face.png", "images/mission.png");
I can use the pre-loading method, do some of the single-page picture of a larger number of sites, such as some e-commerce sites, if a one-time loading all pictures, will affect the loading speed, which will result in poor user experience.
We can handle this problem with the pre-loading function above.
Logic:
1. Loading the page for the first time, passing in some parameters (the parameter here is the picture path);
2. When the window view is sliding to the last picture loaded last, another part of the parameter is passed in;
3. Pass the parameter so repeatedly, as long as the User window view arrives at the last pass of the picture, it passes the next parameter to be loaded;
4. This will not cause unnecessary waste of resources (no need to load all images at once, it is possible that users will not browse all images);
Pre-load Picture