I am importing image files using import so they are being properly included. I'm looking to pre-load some of the image files when the app loads because they are somewhat large and take a few seconds to load even after compressing them. Does create-react-app already have a package that can do this or is there a recommended package to use?
Pretty sure it's not built in and there's no package, but the import resolves to the final path of the file so just preload however you normally would.
import logo from './logo.png';
function preloadImage(url) {
const img = new Image();
img.src = url;
}
preloadImage(logo);
Thanks. If I can't find a suitable package to do it I'll just do that.
Yep, that's the recommended approach.
Most helpful comment
Pretty sure it's not built in and there's no package, but the import resolves to the final path of the file so just preload however you normally would.