http-compression is a lightweight Node.js library designed to add Gzip and Brotli compression capabilities to HTTP servers. Currently at stable version 1.1.3, it primarily functions as Express-style middleware but can also be integrated directly with Node.js's `http.createServer` primitives. The project maintains a steady, albeit infrequent, release cadence, with recent updates focused on dependency maintenance and minor feature enhancements. Key differentiators include its extremely small footprint (< 1kB) with no external dependencies, automatic detection of the best compression encoding (Gzip or Brotli) based on the `Accept-Encoding` header, and configurable compression levels, response size thresholds, and MIME type filtering. It requires Node.js version 18 or greater.
No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
The package exports its main factory function as the default export. This function is called with options to create the middleware.
For CommonJS environments, the factory function is directly exported via `module.exports`.
Demonstrates how to integrate `http-compression` with a native Node.js HTTP server, applying custom compression settings for responses larger than a specified threshold.
Breaking-change detection hasn't run for this library yet.
CVE tracking and dependency tree are planned for a later release.
No traffic data recorded yet.