Categories
HTML

How to cache an image in HTML?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *