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

gzip-compressor

v1.0.1

Published

gzip-compressor is a command-line tool for compressing files in a build directory using Gzip compression. It's designed to be used as part of a build process for web projects, helping to reduce file sizes for faster content delivery.

Downloads

128

Readme

gzip-compressor

gzip-compressor is a command-line tool for compressing files in a build directory using Gzip compression. It's designed to be used as part of a build process for web projects, helping to reduce file sizes for faster content delivery.

Features

  • Recursively compresses files in a specified directory
  • Configurable compression level
  • Selectable file extensions for compression
  • Preserves original files, creating compressed versions alongside them

Installation

You have two options to use gzip-compressor:

1. Global Installation

To install the package globally, you need to have Node.js installed on your system. Then, you can install using npm:

npm install -g gzip-compressor

2. Using npx (No Installation Required)

If you prefer not to install the package globally, you can use npx to run it directly. This method requires no installation, but you still need to have Node.js installed on your system.

Usage

If Installed Globally

After global installation, you can run the tool from the command line:

gzip-compressor --path ./build --level 7 --extensions .html,.css,.js

Or using the short options:

gzip-compressor -p ./build -l 7 -e .html,.css,.js

Using npx (Without Installation)

To use the tool with npx without installing it, run:

npx gzip-compressor --path ./build --level 7 --extensions .html,.css,.js

Or using the short options:

npx gzip-compressor -p ./build -l 7 -e .html,.css,.js

Options

  • --path, -p: (Required) Path to the build directory

    • Type: string
    • Description: The directory containing the files you want to compress
  • --level, -l: (Optional) Gzip compression level

    • Type: number
    • Default: 9
    • Range: 1-9
    • Description: The compression level to use (1 = fastest, 9 = best compression)
  • --extensions, -e: (Optional) File extensions to compress

    • Type: string
    • Default: ".html,.css,.js,.json,.svg"
    • Description: Comma-separated list of file extensions to include in compression
  • --help, -h: Show help information

Examples

  1. Compress all default file types in the 'dist' folder with maximum compression:

    gzip-compressor --path ./dist

    or with npx:

    npx gzip-compressor --path ./dist
  2. Compress only HTML and CSS files in the 'public' folder with fast compression:

    gzip-compressor --path ./public --level 1 --extensions .html,.css

    or with npx:

    npx gzip-compressor --path ./public --level 1 --extensions .html,.css
  3. Compress all JavaScript files in the 'build' folder with medium compression:

    gzip-compressor -p ./build -l 5 -e .js

    or with npx:

    npx gzip-compressor -p ./build -l 5 -e .js

How It Works

The tool performs the following steps:

  1. Parses command-line arguments to get the build directory, compression level, and file extensions.
  2. Recursively scans the specified directory for files.
  3. For each file with a matching extension, it creates a Gzip-compressed version with a .gz extension.
  4. Logs the compression progress and any errors encountered.

Notes

  • The original files are preserved; compressed versions are created alongside them.
  • The tool uses the zlib module for compression, which is part of Node.js core.
  • Errors during compression will be logged, and the process will exit with a non-zero status code.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License