Lightweight Image/Picture lazyload based on Intersection API

vue-lazy

Lightweight Image/Picture lazyload based on Intersection API.

Benefits

  • Lightweight
  • Picture tag support

Usage

There are two ways to use it.

Globally

import Vue from 'vue'
import VueLazy from 'vue-lazy'
import 'vue-lazy/dist/vue-lazy.css'

Vue.use(VueLazy)

Locally

import { LazyImage } from 'vue-lazy'
import 'vue-lazy/dist/vue-lazy.css'

export default {
  components: {
    LazyImage
  }
}

Examples

If you want to see live examples, please jump to Storybook page.

Image

<lazy-image
  src="https://via.placeholder.com/250"
  alt="example aternative text"
/>

Image with known width (prevent jumping content on page)

<lazy-image
  src="https://via.placeholder.com/250"
  alt="example aternative text"
  width="250"
  height="250"
/>

Picture

<picture>
  <source media="(min-width:1366px)" srcset="https://via.placeholder.com/1360x300">
  <source media="(min-width:1024px)" srcset="https://via.placeholder.com/1024x300">

  <lazy-image
    src="https://via.placeholder.com/250"
    alt="example aternative text"
  />
</picture>

GitHub