Updated javascript to not download both images on load