/** * Preloads images specified by the CSS selector. * @function * @param {string} [selector='img'] - CSS selector for target images. * @returns {Promise} - Resolves when all specified images are loaded. */ const preloadImages = (selector = 'img') => { return new Promise((resolve) => { // The imagesLoaded library is used to ensure all images (including backgrounds) are fully loaded. imagesLoaded(document.querySelectorAll(selector), {background: true}, resolve); }); }; // Preload fonts const preloadFonts = (id) => { return new Promise((resolve) => { WebFont.load({ typekit: { id: id }, active: resolve }); }); }; // Exporting utility functions for use in other modules. export { preloadImages, preloadFonts };