const loadImagePromises = new Map();
/** Attempts to load the image and returns a boolean indicating success or not. */
export function loadImageUrl(url) {
    let promise = loadImagePromises.get(url);
    if (promise)
        return promise;
    promise = new Promise(resolve => {
        const img = new Image();
        img.onload = () => {
            // After this event occurs, you can use the url in the DOM. The browser will not make another request for the image; there will be no delay.
            resolve(true);
        };
        img.onerror = () => {
            resolve(false);
        };
        img.src = url;
    });
    loadImagePromises.set(url, promise);
    return promise;
}
//# sourceMappingURL=images.js.map