GithubHelp home page GithubHelp logo

willyw2k / vue-tiny-lazyload-img Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mazipan/vue-tiny-lazyload-img

0.0 1.0 0.0 2.39 MB

๐ŸŒ A small size Vue.js directive for lazy loading images using IntersectionObserver API

Home Page: https://mazipan.github.io/vue-tiny-lazyload-img/

License: MIT License

JavaScript 46.54% Vue 33.61% HTML 19.85%

vue-tiny-lazyload-img's Introduction

๐ŸŒ vue-tiny-lazyload-img

A small size Vue.js directive for lazy loading images using IntersectionObserver API

Travis License version downloads minified

Demo Page

https://mazipan.github.io/vue-tiny-lazyload-img/

Usage

Download

npm install vue-tiny-lazyload-img
// OR
yarn add intersection-observer

Install Plugin

import VueTinyLazyloadImg from 'vue-tiny-lazyload-img'
Vue.use(VueTinyLazyloadImg);

HTML Snippet

<img v-lazyload
  src="./assets/logo.png"
  data-src="./assets/logo-success.png"
  data-err="./assets/logo-error.png">

Please Use polyfill

This plugin using IntersectionObserver, so please use polyfill if you need support old browser

$ yarn add intersection-observer

// then add polyfill for IntersectionObserver in your main app
require('intersection-observer')
  • The easiest way to load the IntersectionObserver polyfill and have it work in the widest range of browsers is via polyfill.io, which will automatically include dependencies where necessary:
<script src="https://polyfill.io/v2/polyfill.min.js?features=IntersectionObserver"></script>

Build Setup

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production demo with minification
npm run build:demo

# build for plugin distribution file
npm run build:lib

Credit

Based on this awesome article: https://developers.google.com/web/fundamentals/performance/lazy-loading-guidance/images-and-video/


Copyright ยฉ 2018 Built with โค๏ธ by Irfan Maulana

vue-tiny-lazyload-img's People

Contributors

dependabot-preview[bot] avatar mazipan avatar dependabot[bot] avatar imgbot[bot] avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.