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

sac

v1.5.10

Published

Small and Crunchy, a minifying asset server.

Downloads

19

Readme

Small and Crunchy

SaC is a tiny service to take big things and make them small. It accepts requests for minified CSS or JS files, expects to find non-minified copies on-disk, and serves up the minified one you asked it for.

Installation

npm install -g sac

Usage

sac

Seriously, that's it (unless you need to change the defaults, see the section on "Configuration").

SaC will launch, check the number of cores on your system, and spawn a minion for each core. It will then listen on port 40480 and accept requests for any resource ending in .min.js, or .min.css. When it gets a request, it will find the unminified file version, and respond with a minified copy.

Example

Assuming default configuration...

curl http://localhost:40480/scripts/jquery.min.js

SaC looks for jquery.js at /data/www/docroot/scripts/jquery.js

If it exists, /usr/bin/r.js is called and the result is returned in the response body with a 200 status in the header. Content-Type is set to either application/javascript or text/css, depending on the content.

HTTP Status Codes

SaC will return reasonably sane HTTP status codes with most responses.

  • 200: Success
    • This is the expected response, when everything goes as planned.
  • 403: Forbidden
    • SaC will refuse requests for non-minified resources. It is a minifying asset server, after all.
  • 404: Not Found
    • The file doesn't exist under the configured docroot.
  • 415: Unsupported Media Type
    • The requested asset isn't of a supported type.
  • 418: I'm a teapot.
    • Request did not include a specific resource. Asking to minify nothing is an interesting concept.
  • 500: Error
    • Something went wrong. The response body should include details.

Configuration

SaC has some (not many) configurable options, mostly to accomodate systems that don't line up with the defaults. These are all passed in as runtime arguments.

docroot (default: /data/www/docroot)

This is where SaC expects to find the canonical assets.

sac --docroot </path/to/docroot>

port (default: 40480)

The port SaC will listen on for connections (a web-accessible status page can be found at (port + 1)).

Attempting to bind to a port below 1024 will require root, and is generally advised against.

sac --port <1025-65534>

requirejs (default: /usr/bin/r.js)

Since SaC uses requirejs to minify content, it needs to know where to find it. This may vary by operating system and configuration.

  • On most Linux systems, requirejs installs to '/usr/bin/r.js' via npm. This is the default assumption.
  • On BSD derivatives (including OSX), it is usually found at /usr/local/bin/r.js.
  • On Solaris and derivatives (including SmartOS), it's probably somewhere else (/opt/local/bin/r.js or something along those lines).

If you're not sure where to find it, you can check with 'which r.js'.

sac --requirejs /usr/local/bin/r.js