JS: Pre-Cache Image

By Xah Lee. Date: .

How to pre-cache Images?

Like this:

(new Image()).src = "myphoto.jpg";

The Image is a constructor that returns a HTMLImageElement object, which represents the image element.

Image Rollover