Since you're not deleting the getThumbnailDom() function, it might be more efficient to call that here rather than do a querySelectorAll(). So maybe move the dom.thumbnails.removeCall(getThumbnailDom(filename)) call above to here and use that instead.