All Projects → barretlee → Lazyload

barretlee / Lazyload

Licence: mit
Lazyload images or lazy execute scripts. (图片脚本懒加载)

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Lazyload

vue-viewload
vue图片懒加载lazyload,依赖vue2.0以上版本。支持图片或者其他资源进入可视区域后加载。
Stars: ✭ 77 (-11.49%)
Mutual labels:  lazyload
React Lazy Load Image Component
React Component to lazy load images and components using a HOC to track window scroll position.
Stars: ✭ 755 (+767.82%)
Mutual labels:  lazyload
Vue Lazy Component
🐌 Vue.js 2.x 组件级懒加载方案-Vue.js 2.x component level lazy loading solution
Stars: ✭ 915 (+951.72%)
Mutual labels:  lazyload
Accessible Image Lazy Load
😴 gandul! accessible lazy loading images
Stars: ✭ 281 (+222.99%)
Mutual labels:  lazyload
Progressively
A JavaScript library to load images progressively 🌇
Stars: ✭ 691 (+694.25%)
Mutual labels:  lazyload
Nuxt Lazysizes
Lazysizes module for Nuxt.js
Stars: ✭ 25 (-71.26%)
Mutual labels:  lazyload
magento2-catalog-lazy-load
Improve the load time of your Magento 2 categories pages by loading your images on demand with our Lazy Load Extension
Stars: ✭ 56 (-35.63%)
Mutual labels:  lazyload
Responsively Lazy
Lazy load responsive images
Stars: ✭ 1,080 (+1141.38%)
Mutual labels:  lazyload
Vanilla Lazyload
LazyLoad is a lightweight, flexible script that speeds up your website by deferring the loading of your below-the-fold images, backgrounds, videos, iframes and scripts to when they will enter the viewport. Written in plain "vanilla" JavaScript, it leverages IntersectionObserver, supports responsive images and enables native lazy loading.
Stars: ✭ 6,596 (+7481.61%)
Mutual labels:  lazyload
Ng Lazy Load
Lazy loading images with Angular.
Stars: ✭ 12 (-86.21%)
Mutual labels:  lazyload
React Lazyload Fadein
React component to lazyload children with a nice fadein effect.
Stars: ✭ 305 (+250.57%)
Mutual labels:  lazyload
React Lazyload
Lazy load your component, image or anything matters the performance.
Stars: ✭ 5,408 (+6116.09%)
Mutual labels:  lazyload
Mediawiki Lazyload
An extension to delay loading of images on MediaWiki pages.
Stars: ✭ 8 (-90.8%)
Mutual labels:  lazyload
angular4-seed-starter
An angular4 starter with webpack2+aot+lazyload+hmr+scss(个人搭的angular4 starter,使用webpack2,包含aot、lazyload、scss、热替换功能等等)
Stars: ✭ 23 (-73.56%)
Mutual labels:  lazyload
Zsh Lazyload
zsh plugin for lazy load commands and speed up start up time of zsh
Stars: ✭ 33 (-62.07%)
Mutual labels:  lazyload
ngx-progressive-image-loader
lazy load img/picture, prevent reflow and seo friendly.
Stars: ✭ 35 (-59.77%)
Mutual labels:  lazyload
React Simple Img
🌅 React lazy load images with IntersectionObserver API and Priority Hints
Stars: ✭ 905 (+940.23%)
Mutual labels:  lazyload
Yall.js
A fast, flexible, and small SEO-friendly lazy loader.
Stars: ✭ 1,163 (+1236.78%)
Mutual labels:  lazyload
Jquery.lazy
A lightweight, fast, feature-rich, powerful and highly configurable delayed content, image and background lazy loading plugin for jQuery & Zepto.
Stars: ✭ 965 (+1009.2%)
Mutual labels:  lazyload
Lozad.js
🔥 Highly performant, light ~1kb and configurable lazy loader in pure JS with no dependencies for responsive images, iframes and more
Stars: ✭ 6,932 (+7867.82%)
Mutual labels:  lazyload

Lazyload

A mini lazyload component within 100 lines code, support amd/cmd require.

文章导读 in Chinese: http://www.barretlee.com/blog/2015/11/16/lazyload-component/

Live Demo: http://barretlee.github.io/lazyload/demo/index.html

Usage

Include the lazyload scirpt to your html:

<script src="https://raw.githubusercontent.com/barretlee/lazyload/master/index.js"></script>

<div class="box">
  <div class="item"><img src data-src="img-path"></div>
  <div class="item"><textarea>alert(1)</textarea></div>
</div>

It exports an api to global:

new Lazyload('.box .item', {
  callback: function(){
    console.log("All item loaded");
  }
});

Params

There are two param your can set when get an Lazyload instance:

new Lazyload('.item', {
  tag: "data-src",
  distance: 0,
  callback: function(){
    // ...
  }
});
  • tag, default is 'data-src', we set the lazyload image 'src' to null, then read 'data-src' attribute;
  • distance, default is 0, if you want to show the lazyload element in advance, you can set it to a positive number;
  • callback, when all item loaded, it will trigger.

Also, two more api:

var lazyload = new Lazyload();
lazyload.pause();
setTimeout(function(){
  lazyload.restart();
});
  • .pause(), pause the lazyload use the inner variable _pause;
  • .resetart(), set _pause false;

Liscese

Under MIT Liscese. Copyright (c) 2015 小胡子哥(Barret Lee)

changelog

  • 2015-11-20
    • add callback function
    • add pause and restart function
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].