npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

progressive-image.js

v1.6.1

Published

progressive lazy-loading image system

Downloads

157

Readme

progressive-image.js

demonstration | GitHub | npm | donate | @craigbuckler | craigbuckler.com

progressive-image.js implements a progressively-loaded image effect similar to those seen on Facebook and Medium. A very small blurred image is replaced with the full-resolution equivalent when the element is scrolled into view.

Please use the code as you wish. Tweet me @craigbuckler if you find it useful and consider donating toward development.

Benefits:

  • saves unnecessary bandwidth
  • fast loading, high performance, images loaded on view
  • supports any image type (JPEG photographs are most appropriate)
  • supports responsive images (srcset and sizes attributes)
  • supports CSS background images
  • supports native lazy loading and aspect ratios
  • lightweight: 1,407 bytes of JavaScript, 407 bytes of optional CSS (minified)
  • any CSS reveal effect can be applied
  • no external dependencies - works with any framework
  • makes up to three attempts if images fail to download
  • works in all modern browsers (IE10+)
  • progressively-enhanced to work in older browsers
  • easy to use

View demonstration and full documentation...

Basic usage

Include the minified CSS and JavaScript anywhere in your page:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/progressive-image.js/dist/progressive-image.css">
<script src="https://cdn.jsdelivr.net/npm/progressive-image.js/dist/progressive-image.js" async></script>

or use npm and a bundler:

npm i progressive-image.js

Then add progressively-loaded images:

<a href="full.jpg" class="progressive replace">
  <img src="tiny.jpg" class="preview" alt="image" />
</a>

where:

  • full.jpg is the large image.
  • tiny.jpg is a small preview image - typically 20px width.

Both images must have the same aspect ratio.

Refer to demo.html for full documentation, examples, options, and usage notes. It is also available as a CodePen demonstration page.

Version history

v1.6.1, 2 October 2021

  • fixed page resize removing responsive srcset images

v1.6.0, 3 July 2020

  • improved browser support verification
  • more resilient to framework issues
  • minor refactoring
  • updated help and images
  • bugfix: script now works in HTML <head>

v1.5.0, 6 June 2020

  • pageshow event for Single Page Apps
  • more reliable MutationObserver
  • class names applied to the preview are applied to the full image (except preview)
  • smaller, better performance
  • no errors in older browsers
  • updated usage notes, including native lazy loading

v1.4.1, 9 July 2019

  • strict mode
  • srcset and sizes attributes only set when available
  • README and demo.html update

v1.4.0, 24 June 2019

  • retries download after 3s and 6s (suggestion from cheuksing)
  • continues to show preview if full image download fails
  • autoprefixer update

v1.3.0, 30 May 2019

  • Gulp.js minification
  • published on npm, CDN information

v1.2.0, 13 April 2018

  • added CSS background image support information

v1.2.0, 9 April 2018

  • full image replaces preview in-place (PR from ftaiolivista)
  • minor refactoring and simplification

v1.1.0, 25 November 2017

  • permits any container element
  • link to other URLs can be retained
  • mutation observer event detects elements added via JavaScript
  • minor performance tweaks

v1.0.0, 16 January 2017

  • Initial commit