Sometimes, we want to cache an image in HTML.
In this article, we’ll look at how to cache an image in HTML.
How to cache an image in HTML?
To cache an image in HTML, we can add a link element.
For instance, we write
<link rel="preload" href="bg-image-wide.png" as="image" />
to add a link element that has the href
attribute set to the URL of the image to cache.
And we set the rel
attribute to preload
to preload the image.
Conclusion
To cache an image in HTML, we can add a link element.