{"id":717,"date":"2012-06-01T19:07:45","date_gmt":"2012-06-01T19:07:45","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=717"},"modified":"2012-06-01T19:07:45","modified_gmt":"2012-06-01T19:07:45","slug":"jquery-preload-images","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/jquery-preload-images\/","title":{"rendered":"jQuery Preload Images Using Custom Function Example"},"content":{"rendered":"<p>Have you ever wanted to speed up the process of preloading images using jQuery? Here is an excellent way to <em><strong>use jQuery to preload images<\/strong><\/em>.<!--more--><\/p>\n<h2>How to Preload Images using jQuery<\/h2>\n<p>The following is a sample code. Simply replace the values of &#8220;my_images&#8221; array with the proper path of your images are you are done!<\/p>\n<h3>Example 1: Use jQuery to Preload Images<\/h3>\n<pre class=\"lang:xhtml decode:true\">&lt;script type=\"text\/javascript\" language=\"javascript\" &gt;\n$(document).ready(function(){\n\n\/\/Function to preload images\nfunction preload_images(images_array)\n{\n$(images_array).each(function () {\n$('&lt;img \/&gt;').attr('src',this).appendTo('body').css('display','none');\n});\n}\n\n\/\/Define an array of images\nvar my_images = ['images\/1.jpg',  'images\/2.jpg', 'images\/3.jpg'];\n\n\/\/Call the function on the array of images\npreload_images(my_images);\n});\n&lt;\/script&gt;<\/pre>\n<h5>That&#8217;s it!<\/h5>\n<p>Do you know of any other ways to <em><strong>preload\u00a0images using jQuery<\/strong><\/em>? Feel free to suggest by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever wanted to speed up the process of preloading images using jQuery? Here is an excellent way to use jQuery to preload images.<\/p>\n","protected":false},"author":1,"featured_media":395,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[20,13],"tags":[41],"class_list":["post-717","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery-tips-and-tricks","category-tips-and-tricks","tag-jquery-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-bz","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/717","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/comments?post=717"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/717\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/media?parent=717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}