This article mainly introduces jquery to implement asynchronous loading (a method of lazy loading of images), which has certain reference value. Interested friends can refer to it.
First introduce the plug-in behind jq
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
Then initialize it at the bottom
1 2 3 4 5 6 7 8 9 10 11 |
|
You need to modify the img tag to
1 |
|
data-url indicates the image to be loaded asynchronously, and src indicates the image to be loaded first (usually a small Picture, or an animation, all src in the web page link to the same picture, so that the web page loads much faster. At this time, the picture to be loaded is loaded asynchronously, which is the function I want to talk about now)
Related recommendations:
Detailed explanation of image lazy loading imgLazyLoading.js
Steps to implement lazy loading and cross-domain implementation using Js
Introduction to the lazy loading method of images using JavaScript
The above is the detailed content of A way to lazily load images with jquery. For more information, please follow other related articles on the PHP Chinese website!