- Notifications
You must be signed in to change notification settings - Fork14
🪧 Universal lazy loading library for placeholder images leveraging native browser APIs
License
NotificationsYou must be signed in to change notification settings
johannschopplich/unlazy
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Universal lazy loading library leveraging native browser APIs. It is intended to be used with theloading="lazy"
attribute alongside (blurry) placeholder images and with aBlurHash orThumbHash string.
- 🎀Native: Utilizes the
loading="lazy"
attribute - 🎛️Framework-agnostic: Works with any framework or no framework at all
- 🌊BlurHash & ThumbHash support: SSR & client-sideBlurHash andThumbHash 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
# pnpmpnpm add -D unlazy# npmnpm i -D unlazy
To apply lazy loading to all images with theloading="lazy"
attribute, import thelazyLoad
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 tolazyLoad
.
- Clone this repository
- EnableCorepack using
corepack enable
- Install dependencies using
pnpm install
- Run
pnpm run dev:prepare
- Start development server using
pnpm run dev
inside the one of thepackages
directories
MIT License © 2023-PRESENTJohann Schopplich
About
🪧 Universal lazy loading library for placeholder images leveraging native browser APIs
Topics
Resources
License
Stars
Watchers
Forks
Packages0
No packages published