vevet
Version:
Vevet is a JavaScript library for creative development that simplifies crafting rich interactions like split text animations, carousels, marquees, preloading, and more.
12 lines • 386 B
JavaScript
export function preloadImage(resource, onLoad) {
if (resource.complete) {
onLoad();
return;
}
const image = new Image();
image.addEventListener('load', () => onLoad());
image.addEventListener('error', () => onLoad());
image.crossOrigin = 'anonymous';
image.src = resource.currentSrc || resource.src;
}
//# sourceMappingURL=preloadImage.js.map