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 🙏

© 2026 – Pkg Stats / Ryan Hefner

spritepack.js

v1.0.0-beta1

Published

Spritepack.js is a Javascript code that will help minimize HTTP requests

Readme

Spritepack.js

Spritepack.js is a Javascript code that will help minimize HTTP requests. Spritepack.js is a fork of Magipack.js

One of the issues on HTTP load time usually are the number of requests and the preferred method to minimize HTTP requests are generating image Spritesheets.

Though, using Spritesheets you end up with some other issues such:

  • Can't use different compressions for each image
  • Can't use Spritesheets that exceeds 2048x2048 in most browsers
  • Hard to use Spritesheets in IMG elements
  • Needs repositioning background-position in CSS when Spritesheets changes

So what Spritepack.js does better than Spritesheets?

It loads a single file which is a concatenation of binary data of the files you want and a json file which maps the position and the size of each file.

This way, you can pack up several images with different file formats in a single file without losing compression or metadatas.

The example files and a python script are in the examples folder so you can easily generate the pack and config file.

So what Spritepack.js does better than Magipack.js?

Spritepack.js bring to Magipack.js Javascript Module support (AMD, CommonJS), it also drop weird IE9 and lower support.

Browser compatibility

This examples were tested in Chrome 32, IE10, Safari 7, Firefox 25, Safari iOS 7.

Spritepack.js need browser support of blob to work.

There wasn't any large scale testing for this project yet, so if you find any issue, please report it.

Installation

  • npm : npm install -S spritepack.js
  • bower : bower install -S spritepack.js

Examples

example1-static.html

example2-instance.html

example3-preloadjs.html

example4-browserify.html

Using as static class

Spritepack.init();
Spritepack.onLoadComplete = function()
{
	document.getElementById("i1").src = Spritepack.getURI('forkit.gif');
	document.getElementById("i2").src = Spritepack.getURI('mario.jpg');
	document.getElementById("i3").src = Spritepack.getURI('Smile.png');
	document.getElementById("container").style.backgroundImage = 'url(' + Spritepack.getURI('packman_ghost.gif') + ')';
}

Spritepack.load('images.pack', 'images.json');

Using as an instance

var sp = new Spritepack();
sp.onLoadComplete = function()
{
	// Here you can use either the instance you created or `this` scope.
	document.getElementById("i1").src = this.getURI('forkit.gif');
	document.getElementById("i2").src = sp.getURI('mario.jpg');
	document.getElementById("i3").src = sp.getURI('Smile.png');
	document.getElementById("container").style.backgroundImage = 'url(' + sp.getURI('packman_ghost.gif') + ')';
}
sp.load('images.pack', 'images.json');

Using with Preload.js

var queue = new createjs.LoadQueue();
queue.on("complete", handleComplete, this);
queue.loadManifest([
	{id: "image", src:"images.pack", type: 'binary'},
	{id: "config", src:"images.json"},
]);
function handleComplete() {
	var sp = new Spritepack(queue.getResult('image'), queue.getResult('config'));
	document.getElementById("i1").src = sp.getURI('forkit.gif');
	document.getElementById("i2").src = sp.getURI('mario.jpg');
	document.getElementById("i3").src = sp.getURI('Smile.png');
	document.getElementById("container").style.backgroundImage = 'url(' + sp.getURI('packman_ghost.gif') + ')';
}

Using with Browserify.js

var Spritepack = require('spritepack.js');

function App() {
  console.log('app initialized');

  var sp = new Spritepack();
  sp.load('images.pack', 'images.json');

  sp.onLoadComplete = function() {

    document.getElementById("i1").src = sp.getURI('forkit.gif');
    document.getElementById("i2").src = sp.getURI('mario.jpg');
    document.getElementById("i3").src = sp.getURI('Smile.png');
    document.getElementById("container").style.backgroundImage = 'url(' + sp.getURI('packman_ghost.gif') + ')';

  }

}

module.exports = App;

Packing images with packImages.py

In terminal, if you are in UNIX system, set permissions to execute script

chmod 0755 packImages.py

Then run it:

./packImages.py -p <path> -o <output>

Both path and output are optional parameters and it will fallback to the same directory as the packImages.py script.

Planned features

  • Port packImages to Javascript
  • Make a gulp plugins to easily use Spritepack.js in your workflow
  • Make a vue.js custom directive to set source of an image from the DOM

Credits

License

The MIT License (MIT)