Is the function I wrote below enough to preload images in most, if not all, browsers commonly used today?
function preloadImage(url) { var img=new Image(
const preloadImage = src => new Promise(r => { const image = new Image() image.onload = r image.onerror = r image.src = src }) // Preload an image await preloadImage('https://picsum.photos/100/100') // Preload a bunch of images in parallel await Promise.all(images.map(x => preloadImage(x.src)))