


Detailed description of image lazy loading technology using jquery plug-in_jquery
Here it is recommended to use the jquery image lazy loading plug-in jquery.lazyload to implement delayed image loading and improve website opening speed. Download address: http://www.appelsiini.net/download/jquery.lazyload. js
1. Quick Use Chapter
1. Import JS plug-in
2. Add the following javascript to your page:
This will cause all images to be loaded lazily;
2. Detailed introduction to the advanced chapter (I don’t want to know so much can be bypassed directly)
Lazy Load is a jQuery plug-in written in JavaScript. It can delay loading of images in long pages. Images outside the browser's visible area will not be loaded until the user Scroll the page to where they are. This is the opposite of how image preloading is handled.
Lazy loading of images on long pages with many large images can speed up page loading. The browser will load visible images before After that, it enters the ready state. In some cases, it can also help reduce server load.
Lazy Load is inspired by the YUI ImageLoader toolbox produced by Matt Mlinac.
How to use?
Lazy Load depends on jQuery. Please Add the following code to the page head area:
And add the following statement to your execution code:
$("#xd").lazyload();
This will cause the images under the id="xd" area to be lazy loaded.
Set sensitive The
plug-in provides the threshold option, which can control the loading of images by setting the threshold value (the distance from where the loading is triggered to the image). The default value is 0 (loaded when the image boundary is reached).
view sourceprint?$ ("#xd").lazyload({ threshold : 200 });
Set the threshold as 200, and start loading the image when the visible area is 200 pixels away from the image. (The literal meaning of this sentence The meaning is inconsistent with my understanding. Original text: Setting threshold to 200 causes image to load 200 pixels before it is visible.)
Placeholder image
You can also set a placeholder image and define events to trigger the loading action. At this time, you need to set a URL address for the placeholder image. Transparent, gray and white 1×1 pixel images are already included in the plug-in.
Event triggered loading
The event can be any jQuery event, such as: click and mouseover. You can also use custom events, such as: sporty and foobar. By default, it is in a waiting state until the user scrolls to the position of the picture on the window. In the gray placeholder To prevent the image from loading before it is clicked, you can do this:
$("img").lazyload({
placeholder : "img/grey.gif",
event : "click"
});
Use special effects
When the image is fully loaded, the plug-in uses the show() method to display the image by default. In fact, you can use any special effects you want to process. The following code uses the FadeIn effect. This is the demo page.
$("img").lazyload({
placeholder : "img/grey.gif",
effect : "fadeIn"
});
The image is inside the container
You can use the plug-in on images in scrollable containers, such as DIV elements with scroll bars. All you have to do is define the container as a jQuery object and pass it as a parameter to the initialization method. . This is a horizontal scrolling demo page and a vertical scrolling demo page.
CSS code:
#container { height: 600px;overflow: scroll; }
JavaScript code:
$("img").lazyload({
placeholder : "img/grey.gif ",
container: $("#container")
});
When the images are not arranged in order
When the page is scrolled, Lazy Load will cycle through the loaded images . Check whether the image is within the visible area in the loop. By default, the loop stops when the first image is found that is not in the visible area. Images are considered to be distributed in a fluid manner, and the order of the images in the page and the order in the HTML code The same. But in some layouts, this assumption is not true. However, you can control the loading behavior through the failurelimit option.
$("img").lazyload({
failurelimit : 10
});
Set failurelimit to 10 Let the plug-in find 10 images that are not in the visible area before stopping the search. If you have a cumbersome layout, please set this parameter higher.
Lazy loading of images
An incomplete function of the Lazy Load plug-in. But this can also be used to implement delayed loading of images. The following code implements loading after the page is loaded. 5 seconds after the page is loaded, the images in the specified area will be automatically loaded. This is a delayed loading demonstration page.
$(function() {
$("img: below-the-fold").lazyload({
placeholder : "img/grey.gif",
event : "sporty"
});
});
$(window ).bind("load", function() {
var timeout = setTimeout(function() {$("img").trigger("sporty")}, 5000);
});

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.

The power of the JavaScript framework lies in simplifying development, improving user experience and application performance. When choosing a framework, consider: 1. Project size and complexity, 2. Team experience, 3. Ecosystem and community support.

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.
