All Projects → tvler → Lazy Progressive Enhancement

tvler / Lazy Progressive Enhancement

Licence: mit
A lazy image loader designed to enforce progressive enhancement and valid HTML.

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Lazy Progressive Enhancement

Vanilla Lazyload
LazyLoad is a lightweight, flexible script that speeds up your website by deferring the loading of your below-the-fold images, backgrounds, videos, iframes and scripts to when they will enter the viewport. Written in plain "vanilla" JavaScript, it leverages IntersectionObserver, supports responsive images and enables native lazy loading.
Stars: ✭ 6,596 (+3408.51%)
Mutual labels:  lazyload
Zsh Lazyload
zsh plugin for lazy load commands and speed up start up time of zsh
Stars: ✭ 33 (-82.45%)
Mutual labels:  lazyload
React Lazy
Universal lazy loader components using IntersectionObserver for React
Stars: ✭ 118 (-37.23%)
Mutual labels:  lazyload
React Simple Img
🌅 React lazy load images with IntersectionObserver API and Priority Hints
Stars: ✭ 905 (+381.38%)
Mutual labels:  lazyload
Ng Lazy Load
Lazy loading images with Angular.
Stars: ✭ 12 (-93.62%)
Mutual labels:  lazyload
Responsively Lazy
Lazy load responsive images
Stars: ✭ 1,080 (+474.47%)
Mutual labels:  lazyload
React Lazyload
Lazy load your component, image or anything matters the performance.
Stars: ✭ 5,408 (+2776.6%)
Mutual labels:  lazyload
Ng In Viewport
Allows us to check if an element is within the browsers visual viewport
Stars: ✭ 178 (-5.32%)
Mutual labels:  lazyload
Vue Lazy Component
🐌 Vue.js 2.x 组件级懒加载方案-Vue.js 2.x component level lazy loading solution
Stars: ✭ 915 (+386.7%)
Mutual labels:  lazyload
Androidxlazyload
😈😈Fragment lazy loading under the androix
Stars: ✭ 110 (-41.49%)
Mutual labels:  lazyload
Nuxt Lazysizes
Lazysizes module for Nuxt.js
Stars: ✭ 25 (-86.7%)
Mutual labels:  lazyload
Lozad.js
🔥 Highly performant, light ~1kb and configurable lazy loader in pure JS with no dependencies for responsive images, iframes and more
Stars: ✭ 6,932 (+3587.23%)
Mutual labels:  lazyload
Yall.js
A fast, flexible, and small SEO-friendly lazy loader.
Stars: ✭ 1,163 (+518.62%)
Mutual labels:  lazyload
React Lazy Load Image Component
React Component to lazy load images and components using a HOC to track window scroll position.
Stars: ✭ 755 (+301.6%)
Mutual labels:  lazyload
Defer.js
🥇 A super small, super efficient library that helps you lazy load everything like images, video, audio, iframe as well as stylesheets, and JavaScript.
Stars: ✭ 138 (-26.6%)
Mutual labels:  lazyload
Progressively
A JavaScript library to load images progressively 🌇
Stars: ✭ 691 (+267.55%)
Mutual labels:  lazyload
Jquery.lazy
A lightweight, fast, feature-rich, powerful and highly configurable delayed content, image and background lazy loading plugin for jQuery & Zepto.
Stars: ✭ 965 (+413.3%)
Mutual labels:  lazyload
React In Viewport
Detect if React component is in viewport
Stars: ✭ 183 (-2.66%)
Mutual labels:  lazyload
Douban Movie
🎥The douban-movie Application built with webpack + vue + vuex + vue-router + iView.
Stars: ✭ 147 (-21.81%)
Mutual labels:  lazyload
Lazyload
Lazyload images or lazy execute scripts. (图片脚本懒加载)
Stars: ✭ 87 (-53.72%)
Mutual labels:  lazyload

Lazy Progressive Enhancement

Download, copy-paste, whatever ;)

View website

A lazy image loader designed to enforce progressive enhancement and valid HTML.

Not a framework, not a library, just a function (with clean af markup).

<noscript><img ></noscript>
loadMedia(
   element,
   onload,
   scroll
)

element: CSS String | NodeList | Element (optional) – loads all images if not set

onload: Function (optional)

scroll: Boolean (optional) – loads image when visible

Benefits of Lazy Progressive Enhancement

  • Designed to enforce progressive enhancement and valid HTML.
  • Written in pure JS -- no dependencies.
  • Not a framework, not a library, just a function.
  • Works with responsive srcset images.
  • Works with iframes.

Other lazy loaders promote invalid HTML by omitting the src attribute, or aren't compatible for users without javascript.

Contents

Basic Usage

By default, the function targets every noscript element on the page.

Any attributes the image has in noscript (class / id / alt / etc) are kept.

HTML

<noscript><img alt="hello!" ></noscript>

JS

loadMedia()

End result HTML

<img alt="hello!" >

Load Specific Images

You can specify what images to load by passing in either

  1. A CSS selector string (use if calling the function before DOMContentLoaded)
  2. A NodeList of noscripts (from something like document.querySelectorAll)
  3. A singular noscript Element (from something like document.querySelector)

HTML

<noscript id="this-one"><img ></noscript>
<noscript id="not-this-one"><img ></noscript>

JS

loadMedia('#this-one')

End result HTML

<img >
<noscript id="not-this-one"><img ></noscript>

onload Function

You can hook an onload function for every loaded image

JS

loadMedia(null, function() {
   this.classList.add('loaded')
})

End result HTML

<img class="loaded" >

Scroll-Based Loading

There's a default function to load images when they're scrolled into view.

This is a general solution, creating your own scroll-based loading functionality may be more performant.

Will be updated to use intersection observers when it becomes standardized.

JS

loadMedia(null, null, true)

Build

uglifyjs lazy-progressive-enhancement.js -m --comments > lazy-progressive-enhancement.min.js

Thanks

@agarzola, @raglannyc

-- MIT License (MIT)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].