var first = new Image();
var second = new Image();
var one = new Image();
one.onload = function() {
runFunction();
}
var a = new Image();
var b = new Image();
var loadedCounter = 0;
a.src = '//lorempixel.com/400/200/sports/'
b.src = '//lorempixel.com/400/200/cats/'
a.onload = b.onload = function() {
loadedCounter++;
if (loadedCounter == 2) {
runFunction();
}
}