const ufo = new Image(); ufo.src = "sprites/ufo.png"; const spriteData = { "ufo": {} }; ufo.onload = function () { spriteData.ufo.width = this.width; spriteData.ufo.height = this.height; }