js reload image code example
Example 1: preload images javascript
<script>
var myimages=new Array()
function preloadimages(){
for (i=0;i<preloadimages.arguments.length;i++){
myimages[i]=new Image()
myimages[i].src=preloadimages.arguments[i]
}
}
preloadimages("http://mydomain.com/firstimage.gif","http://mydomain.com/secondimage.gif","http://mydomain.com/thirdimage.gif")
</script>
Example 2: preload images javascript
let preloadedMaps = [];
let preloadedWorkRoutes = [];
console.log('asdasdasdas')
function preloadImages(preloadedMaps, preloadedWorkRoutes){
var maps = [`${workMapDesktop}`, `${workMapMobile}`, `${playMapDesktop}`, `${playMapMobile}`];
var workRoutes = workRoutesDesktop.concat(workRoutesMobile);
for(let i = 0; i < workRoutes.length; i++) {
preloadedWorkRoutes[i] = new Image();
preloadedWorkRoutes[i].src = workRoutes[i]
}
for(let i = 0; i < maps.length; i++) {
preloadedMaps[i] = new Image();
preloadedMaps[i].src = maps[i]
}
}
preloadImages(preloadedMaps, preloadedWorkRoutes);