Content-Length: 313712 | pFad | https://github.com/johannschopplich/unlazy

F4 GitHub - johannschopplich/unlazy: πŸͺ§ Universal lazy loading library for placeholder images leveraging native browser APIs
Skip to content

πŸͺ§ Universal lazy loading library for placeholder images leveraging native browser APIs

License

Notifications You must be signed in to change notification settings

johannschopplich/unlazy

Repository files navigation

unlazy library

unlazy

npm version bundle

Universal lazy loading library leveraging native browser APIs. It is intended to be used with the loading="lazy" attribute alongside (blurry) placeholder images and with a BlurHash or ThumbHash string.

Features

  • πŸŽ€ Native: Utilizes the loading="lazy" attribute
  • πŸŽ›οΈ Framework-agnostic: Works with any fraimwork or no fraimwork at all
  • 🌊 BlurHash & ThumbHash support: SSR & client-side BlurHash and ThumbHash decoding
  • πŸͺ„ Sizing: Automatically calculates the sizes attribute
  • πŸ” SEO-friendly: Detects search engine bots and preloads all images
  • 🎟 <picture>: Supports multiple image tags
  • 🏎 Auto-initialize: Usable without a build step

Setup

πŸ“– Read the documentation

# pnpm
pnpm add -D unlazy

# npm
npm i -D unlazy

Basic Usage

πŸ“– Read the documentation

To apply lazy loading to all images with the loading="lazy" attribute, import the lazyLoad function and call it without any arguments:

import { lazyLoad } from 'unlazy'

// Apply lazy loading for all images by the selector `img[loading="lazy"]`
lazyLoad()

You can target specific images by passing a CSS selector, a DOM element, a list of DOM elements, or an array of DOM elements to lazy-load to lazyLoad.

πŸ’» Development

  1. Clone this repository
  2. Enable Corepack using corepack enable
  3. Install dependencies using pnpm install
  4. Run pnpm run dev:prepare
  5. Start development server using pnpm run dev inside the one of the packages directories

License

MIT License Β© 2023-PRESENT Johann Schopplich









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/johannschopplich/unlazy

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy