Lightweight Image Lazy-Loading Component (Original)

Add-ons
2026-07-26 01:09 4 次浏览 • 0 次下载 3.3KB
Lightweight Image Lazy-Loading Component (Original)

Last Updated: 2020-03-20 10:42:55

Changelog:Library version upgraded to v2.1.0; no longer depends on jQuery and is developed entirely using native JavaScript; no longer supports browsers older than IE8.


Download FunLazy v1.0.0(Compatible with IE7)


FunLazy

An image lazy-loading component developed entirely using native JavaScript. It fully supports mainstream modern browsers and prioritizes the use of the Intersection Observer API to improve lazy-loading performance.

Usage

Include Files

1
2
3
<!-- jquery 1.9.0+ -->
<script src="jquery.min.js"></script>
<script src="funlazy.min.js"></script>

Add Attributes

1
2
3
4
5
6
7
8
9
10
11
12
<body>
<img data-funlazy="01.jpg" width="700" height="700">
<img data-funlazy="02.jpg" width="700" height="700">
<img data-funlazy="03.jpg" width="700" height="700">
<img data-funlazy="04.jpg" width="700" height="700">
<img data-funlazy="05.jpg" width="700" height="700">
<img data-funlazy="06.jpg" width="700" height="700">
<img data-funlazy="07.jpg" width="700" height="700">
<img data-funlazy="08.jpg" width="700" height="700">
<img data-funlazy="09.jpg" width="700" height="700">
<img data-funlazy="10.jpg" width="700" height="700">
</body>

Initialize the Component

1
2
3
4
5
$.FunLazy({
onSuccess: function ( el, img ) {
console.log( "Image:" + img + "Loaded" );
}
});

API Parameters

ParametersDescriptionTypeDefault Value
containerTarget container. Default: null, which represents window.Object / Stringnull
effectImage display effect. Available values: show, fadeIn.Stringshow
placeholderPlaceholder imageStringBase64-encoded gray image
errorPlaceholderPlaceholder image displayed when image loading failsString""
thresholdThreshold value, unit: pxNumber0
widthImage width. Numeric values use px as the unit. Percentage values are also supported. Can be set through CSS or inline attributes.Number / Stringnull
heightImage height. Numeric values use px as the unit. Percentage values are also supported. Can be set through CSS or inline attributes.Number / Stringnull
axisContainer scrolling direction. Available values: x, y.Stringy
eventTypeMouse event that triggers image loading. Available values: click, dblclick, mouseover.String""
onSuccessCallback function executed when an image loads successfully. The callback receives two parameters:
1. The element whose image loaded successfully.
2. The successfully loaded image URL.
FunctionEmpty function
onErrorCallback function executed when image loading fails. The callback receives two parameters:
1. The element whose image failed to load.
2. The URL of the image that failed to load.
FunctionEmpty function


星河码客

发现和分享优质开源项目,传承互联网精神,为开发者服务。

关于本站

联系我们

微信/广告合作:ITcloub (备注星河码客)

免责声明:本站资源版权归原作者所有,仅供学习与交流。如有侵权,请通过「关于我们 - 侵权投诉」联系删除。

Powered by Nuxt · Deployed on Cloudflare