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

parcel-plugin-compress

v2.0.2

Published

Parcel plugin that pre-compresses resources with Brotli and Gzip

Downloads

530

Readme

Parcel plugin that precompresses all assets in production mode.

This plugin utilizes @gfx/zopfli, node-zopfli-es and zlib for GZip compression and zlib (Node 11.7.0+) and brotli for Brotli compression.

Installation

npm install parcel-plugin-compress -D

Usage

By default, this plugin doesn't require any extra configuration to get started. If, however, you'd like to be more targeted in how this plugin is applied, you can configure the plugin as needed.

To configure, add a file called .compressrc in your project's root folder, or add a key in your package.json called compress. The available options are below, with the defaults.

{
  // a regular expression to test filenames against
  "test": ".",
  // a number that represents the minimum filesize to compress, in bytes
  "threshold": undefined,
  // Concurrency limit for p-queue
  concurrency: 2,
  // configuration options for gzip compression
  "gzip": {
    "enabled": true,
    "numiterations": 15,
    "blocksplitting": true,
    "blocksplittinglast": false,
    "blocksplittingmax": 15,
    // use zlib instead of zopfli if zlib is true
    "zlib": false,
    "zlibLevel": 9,
    "zlibMemLevel": 9
  },
  // configuration options for brotli compress
  "brotli": {
    "enabled": true,
    "mode": 0, // 0 = generic, 1 = text, 2 = font (used in WOFF 2.0)
    "quality": 11, // 0 - 11, 11 = best
    "lgwin": 24, // 10 - 24    
    "enable_context_modeling": true, // disabling decreases compression ratio in favour of decompression speed
    "lgblock": undefined, // 16 - 24
    "nPostfix": undefined, // 0 - 3
    "nDirect": undefined // 0 to (15 << nPostfix) in steps of (1 << nPostfix)
  },
  // a flag that changes the behavior of the plugin, by default this option is disabled
  // and the plugin compresses all the files it receives via the Parcel bundle object
  // and match the test regular expression
  //	
  // if true the plugin compresses all files in the output directory and subdirectories
  // that match the test regular expression
  compressOutput: false
}

Browser Support for Brotli

Current versions of the major browsers send br in the Accept-Encoding header when the request is sent over TLS

Support introduced in version ...

  • Edge 15
  • Firefox 44
  • Chrome 50
  • Safari 11

Server support

To take advantage of precompressed resources you need a server that is able to understand the Accept-Encoding header and serve files ending with .gz and .br accordingly.

Nginx

Nginx supports Gzip compressed files out of the box with the gzip_static directive.

Add this to a http, server or location section and Nginx will automatically search for files ending with .gz when the request contains an Accept-Encoding header with the value gzip.

gzip_static  on;  

See the documentation for more information.

To enable Brotli support you either

  • build the ngx_brotli from source:
    https://www.majlovesreg.one/adding-brotli-to-a-built-nginx-instance
  • or install a pre-built Nginx from ppa with the brotli module included:
    https://gablaxian.com/blog/brotli-compression
  • or use the approach described in this blog post that works without the brotli module:
    https://siipo.la/blog/poor-mans-brotli-serving-brotli-files-without-nginx-brotli-module

Apache HTTP

https://css-tricks.com/brotli-static-compression/
https://blog.desgrange.net/post/2017/04/10/pre-compression-with-gzip-and-brotli-in-apache.html

LightSpeed

Support for Brotli introduced in version 5.2