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

snooze-squad

v0.3.2

Published

A ridiculously simple lazy image loader, written in ES6. Time for a nap I think...

Downloads

8

Readme

SnoozeSquad

Finally a simple lazy image loader (for browsers, not Node.JS!). Written in ES6.

npm version badge npm

Downloading

Download SnoozeSquad from this repo. Links:

Makefile | curl command --------------------------------|----------------------------- SnoozeSquad.js | curl -OL https://github.com/sbrl/SnoozeSquad/raw/master/SnoozeSquad.js SnoozeSquad.min.js | curl -OL https://github.com/sbrl/SnoozeSquad/raw/master/SnoozeSquad.min.js

npm

Snooze Squad is on npm! You can find it under the name snooze-squad, and install it with npm install snooze-squad.

Usage

Using Snooze Squad is really easy. Here's a simple example:

window.snoozeSquad = new SnoozeSquad({});

The first parameter in the above is the options object. You can specify a number of options that are listed below if you want to. Note that the options object is currently required, and SnoozeSquad won't work without it.

Once you've got that set up, change the name of the src attribute of all images that you want to be lazy loaded to data-src. The contents of data-src will be copied over to the src attribute when the image is woken up. Example:

<!-- From this -->
<img src="/path/to/some/image.js" />

<!-- To this -->
<img data-src="/path/to/some/image.js" />

Note that no other attributes will be touched, so you can safely do whatever else you want to your images.

If for some reason the data-src attribute is unsuitable, you change change it with the attributeName parameter (see below).

Snooze Squad should also properly detect which images are currently in the viewport, and load them automatically.

You can also set the src attribute of your lazily-loaded images to a placeholder or other loading image / animation - Snooze Squad will overwrite this with the actual address of the image when the image is lazily loaded.

Options

You can pass Snooze Squad a number of options. Below is an explanation of each:

  • range - The number of screens within the current screen an image is allowed to get before it is woken up.
  • attributeName - The name of the attribute that we should copy over to wake image up.
  • updateInterval - The maximum interval at which we should update. Helps to prevent lag.

Development

Snooze Squad development isn't too complicated either. You'll need [Node.js] and make installed if you want to build / minify Snooze Squad.

Note that if you submit pull requests, it would be helpful if you didn't minify the file yourself if there's alreayd a pull request waiting. That just gets messy.

Setup

If you're on linux, just run make setup in the current directory. If not (or you're on a machine without sudo - how odd!), just run npm install uglify-js-harmony --global instead.

Minification

Just run make in the current directory.

License

Snooze Squad is licensed under the MIT license. See the LICENSE file in this repository.