Preloading images would make your application a bit faster by making it lightweight. It is very-simple and easy-to-create and load DOM elements-in-referring to images-with jQuery. If you want to preload the images using jQuery there here's a detailed explanation on how can does this:
the foremost thing you need to do are create an image DOM element by providing a value for the SRC attribute for the Imag e So, the Web browser would know which image it had to load i.e. preloading the image. You can make use of the below code snippet for preloading an image using JQuery:
12 |
Create an image DOM Elementvar image1 = $ (' '). attr (' src ', ' link.jpg '); |
once you do with creating the DOM image element you must insert this DOM image element inside the DOM tree by Maki ng use of any of the DOM manipulation methods. The most excellent method of doing the-is-to-use, the callback method so, it would insert the preloaded image directly into your application once it has completed loading.
one more the by-make use of a jQuery plug-in to preload the image.
Reference from:http://www.webdeveloperjuice.com/2014/08/06/preloading-an-image-with-jquery/