danbucholtz / st-img

Web Component built with Stencil to lazy load images

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

st-img

Built With Stencil

What is it?

st-img is a web component built with Stencil that allows you to lazy load images as the user scrolls them into the viewport. On supported browsers (Chrome and chrome based browsers, Firefox and Edge) it uses IntersectionObserver to accomplish this functionality. For Safari and IE it simply falls back to setTimeout.

Usage

To use this component in your app, no matter what framework you are using, follow these steps:

  • pop this script tag <script async defer src='https://unpkg.com/st-img@0.1.1/dist/stimg.js'></script> into your index.html

API

Properties:

Examples

 <st-img src="https://madeby.google.com/static/images/google_g_logo.svg" alt="google"></st-img>

About

Web Component built with Stencil to lazy load images

License:MIT License


Languages

Language:TypeScript 61.1%Language:JavaScript 36.1%Language:CSS 2.7%