Preloading an Image with jQuery--reference

Preloading images will make your application a bit faster by making it lightweight. It is very simple and easy to create and load DOM elements (in this case referring to images) with jQuery. If you want to preload images using jQuery there here is a detailed explanation on how you can do this:
• The foremost thing you need to do is create an image DOM element by providing a value for the src attribute for the image so that the web browser will know which image it has to load i.e. preloading the image. You can make use of the below code snippet for preloading an image using jQuery :

1
2
// Create an image DOM  element
var image1 = $(‘<img  />‘).attr(‘src‘, ‘link.jpg‘);

• Once you are done with creating the DOM image element you must insert this DOM image element inside the DOM tree by making use of any of the DOM manipulation methods. The most excellent method of doing this is to use the callback method so that it will insert the preloaded image directly into your application once it has completed loading.
• One more way is to 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/

Preloading an Image with jQuery--reference

时间: 2024-11-04 05:38:02

Preloading an Image with jQuery--reference的相关文章

转:Generating PDFs from Web Pages on the Fly with jsPDF

The Portable Document Format has been one the major innovations in the fields of desktop publishing and office automations. It’s widely used in web publishing too, but unfortunately very often in wrong ways – like using it to replace contents that sh

2015最新最全Java学习资料下载

Java学习资料下载大全 : java的开发建议使用jbuilder.eclipse或是netbeans  eclipse在这里免费下载:http://www.eclipse.org/downloads/ netbeans在这里免费下载:http://dlc.sun.com.edgesuite.net/netbeans/6.0/final/ 教程的话,你可以看看这个: 网盘下载地址:http://pan.baidu.com/s/1hqLl3Vm 密码直通车:521595826(扣扣qun) 精通

avalon学习笔记(五)

五,搭建一个工程环境 到此,基础的理论都搞得差不多了,是时候做个实际的例子 换个教程,根据<avalon学习教程>系列--<1.引入avalon>建立一个新项目. 我用的vs2013community版 首先open->web site,指向一个空目录 新建两个folder,一个modules,一个reference. Modules里存放网站的一个一个模块,reference里面放上我们要用到的第三方库,比如avalon,还有常用的requirejs,jquery等等 按照

Learning JavaScript Design Patterns -- A book by Addy Osmani

Learning JavaScript Design Patterns A book by Addy Osmani Volume 1.6.2 Tweet Copyright © Addy Osmani 2015. Learning JavaScript Design Patterns is released under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 unported license. It

最新JavaScript、Ajax典藏级学习资料下载分类汇总 (2011年12月21日更新)

其他网站开发相关资料            超强HTML和xhtml,CSS精品学习资料下载汇总                                               最新html5以及css3资源下载汇总                                               Dreamweaver 教程汇总 索引: JavaScript初学者及参考必备 Javascript高级进阶 AJAX (Asynchronous JavaScript and

Lazyload Angular

// I lazily load the images, when they come into view. app.directive( "bnLazySrc", function( $window, $document ) { // I manage all the images that are currently being // monitored on the page for lazy loading. var lazyLoader = (function() { //

SignalR 教程一

转帖官方教程:Tutorial: Getting Started with SignalR 2 and MVC 5 http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr-and-mvc This tutorial shows how to use ASP.NET SignalR 2 to create a real-time chat application. You w

SignalR 教程二 服务端广播

转帖官方教程:Tutorial: Server Broadcast with SignalR 2 http://www.asp.net/signalr/overview/getting-started/tutorial-server-broadcast-with-signalr This tutorial shows how to create a web application that uses ASP.NET SignalR 2 to provide server broadcast fu

01.一天一点JQUERY源码——定义函数

(function(window,undefined){ var rootjQuery, readyList, core_strundefined =typeof undefined, location =window.location, document =window.document, docElem =window.documentElement, _jQuery =window.jQuery, _$ = window.$, class2type = {}, //无用了 core_del