Skip to content
Advertisement

Preload images with link tag – remove warning (html/Javascript)

I got the following warning on the console when I try to add <link rel="preload" as="image" href="path"> into the <head>.

{path to image} was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally

I tried to add the crossorigin="anonymous" attribute but the warning persist.

Any ideas how I can remove the warning, please?

Advertisement

Answer

This might happens if the image in question is not part of the page content. This warning will not show if the actual image is on the page itself. If the browser doesn’t find the image on the page, but it is preloaded, you get this warning.

Also preloaded images do not need CORS

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement