js achieve the pre-loaded images

Simple to understand: that is, before using the picture of resources, to be loaded to the local, to the real use, 
request data directly from a local on the line

2.png

11.jpg

Now put a img tag in the page

<img src="" alt=""  id="pic"/>

Modify js code:

3.png

12.jpg

Summary:
1 scene using preloaded

Use 2 Image object

Guess you like

Origin blog.51cto.com/11871779/2404689