JSON photo data parsing
find the first "biggest" url size name. A more convenient way is using Array.prototype.find() method:
p.id can be used directly as a key for object imgUrls - instead of generating constant const id = p.id; for each p(photo)




const imgUrls = {};
const sizes = ['url_o', 'url_6k', 'url_5k', 'url_4k', 'url_3k', 'url_k', 'url_h', 'url_l'];


function onXhrLoad() {
  const json = JSON.parse(js);
  const photos = json.photos ? json.photos.photo : [json.photo];
  for (var p of photos) {   
      imgUrls[p.id] = p[sizes.find((s) =&gt; p[s])];
  }
}