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

uselesscss

v0.0.13

Published

Trim bloat from your CSS by only including rules that will actually be active.

Downloads

5

Readme

uselesscss Build Status

Trim bloat from your CSS by only including rules that will actually be active.

The goal behind this project is to speed up websites and make for cleaner resulting code by only including what you need. A perfect use case, for example, would be if you were using a large framework, like Bootstrap, in combination with a static site generator, like Jekyll.

Install/Run

npm install uselesscss # you can add -g for a global install, available from the command line

Usage

You can use uselesscss through the command line interface or as a library

Command line interface

usage:
  uselesscss [options] <html> ([-] | [<css>])

options:
  -h --help  Show this message
  --version  Print version

Where <html> and <css> are local paths to their respective files. Also, you can supply - instead of a <css>, to pass in STDIN or pipe in output from another program.

To save the resulting output, redirect it to a file. E.g.

./bin/uselesscss ~/index.html ~/Developer/my-site/big.css > ~/small.useless.css

The pipe syntax (i.e. -) is useful when used with a build pipeline or want to pass in a remote file. E.g.

curl -L https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css | ./bin/uselesscss ~/index.html - > bootstrap.useless.css

Library

var Useless = require('uselesscss')
var reducedCss = Useless(html, css)

Where html and css are strings.

Example results

The following examples can be found in the example section of this project. They can be generated easily by running

./bin/uselesscss example/foundation/kitchen_sink.html example/foundation/css/docs.css > example/foundation/css/docs.useless.css
./bin/uselesscss example/bootstrap/bootswatch.html example/bootstrap/css/bootstrap.css > example/bootstrap/css/bootstrap.useless.css

The resulting output is as follows:

| Framework | HTML | Original CSS | New CSS | Original size | New size | % reduction | |------------|------------------------------------------------------------|-------------------------------------------------------|-----------------------------------------------------------------------|---------------|----------|-------------| | Foundation | kitchen_sink.html | docs.css | docs.useless.css | 288KB | 84KB | 70% | | Bootstrap | bootswatch.html | bootstrap.css | bootstrap.useless.css | 146KB | 48KB | 67% |

The above examples were chosen because their original intent is to demonstrate the full capabilities of their respective frameworks. Still, we see pretty good file size reductions. For more realistic projects, such as my personal site, which make much more sparse use of such frameworks, the reduction is closer to 97%!