var proxy = false;
var img = new Image();
img.onload = function () {
proxy = false;
}
img.onerror = function () {
proxy = true;
}
img.src = '...';
console.log('Proxy:', proxy);
function loadImages(imagesArray, callback) {
var imagesStates = {};
var imagesChecked = 0;
var totalImages = imagesArray.length;
for (var i = 0; i < totalImages; i++) {
var src = imagesArray[i];
imagesStates[src] = {"loaded": false};
var img = new Image();
img.onload = function() {
if (this.complete || this.naturalWidth > 0) {
imagesStates[src].loaded = true;
}
imagesChecked++;
if (imagesChecked >= totalImages) {
callback(imagesArray, imagesStates);
}
};
img.onerror = function() {
imagesChecked++;
if (imagesChecked >= totalImages) {
callback(imagesArray, imagesStates);
}
};
img.src = src;
}
}
// ===============================
loadImages(
["src_1.png", "src_2.png", "src_3.png"],
function(imagesArray, imagesStates) {
console.log(imagesStates);
}
);