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 🙏

© 2026 – Pkg Stats / Ryan Hefner

tdewolff-minify

v0.9.0

Published

An ES module with an API allowing easy usage of tdewolff's minify within Node.js

Readme

tdewolff-minify

Description

In search for the best (HTML, CSS, JavaScript, JSON, etc) minifier I happened to come across tdewolff's minify written in Go. Which seems to have awesome performance and capabilities. But it had no JavaScript API (npm library) available to make it easy to plug into a Node.js project; hence I made this one.

With this npm package you just need to npm install tdewolff-minify and it will download the latest native precompiled binary for your platform (by fetching it straight from GitHub). And it comes with a nice JavaScript API for easy usage of the minifier.

Disclaimer

I'm in no way the author of minify or affiliated with his project. I only take credit for creating this JavaScript API which allows easy usage of it within Node.js.

Funding

If you find this useful then please consider helping me out (I'm jobless and sick). For more information visit my GitHub profile.

It would also be a good idea to fund the creator of minify, which you can do here.

How to use

Install using NPM

npm i tdewolff-minify

Usage demo

import {Minify, minifyStream, minifyPath} from 'tdewolff-minify'
import {Writable} from 'node:stream'
const moduleDirectory = import.meta.url.slice(7, import.meta.url.lastIndexOf('/')+1)
const log = console.log

process.chdir(moduleDirectory)

/** Allows a `Writable` stdout stream that doesn't close the actual stdout. */
function stdoutWritable() {
  return new Writable({
    write(chunk, _encoding, callback) {
      process.stdout.write(chunk, callback)
    }
  })
}

/* Initialize the minify controller and allow max 4 running 
minify processes at once. */
const minify = new Minify({maxConcurrency: 4})

/* Since the API is asynchronous it's important to catch errors 
correctly. The minifier will throw errors if it has any trouble 
with the syntax of the file to minify. */

/* Here we try to minify a file: */
try { // (a try/catch block works well with await)
  const result = await minify.file('fileToMinify.js')
  log('success:', result, '\n')
} catch (error) {
  log('error:', error, '\n')
}

/* Here we try to minify a JavaScript we supply: */
minify.content('js', 'let a = 123;')
  .then( // (an alternative to using await)
    result => log('success:', result, '\n'),
    error => log('error:', error, '\n')
  )

/* Here we will do some plumbing: */
const {createReadStream} = await import('node:fs')
// const outStream = fs.createWriteStream('fileToMinify.min.js')
await minify.pipe('js',
  createReadStream('fileToMinify.js'),
  stdoutWritable()
)
log('\n')

/* Here we'll show how to use pipeline:
(if you want to use pipeline then you must handle 
concurrency yourself instead of using the controller)  */
const {createGzip}          = await import('node:zlib')
const {pipeline, Transform} = await import('node:stream')

pipeline(
  createReadStream('fileToMinify.js'), // get the text
  await minifyStream('js'), // minfy it
  createGzip(), // gzip it (like a web-server would do)
  new Transform({ // hex encode it
    transform(chunk, _encoding, callback) {
      callback(null, chunk.toString('hex'))
    }
  }), 
  stdoutWritable(), // and display it
  error => { // the callback when done
    if (error) log('\n', error, '\n')
    else log('\n\nSuccess', '\n')
  }
)

log('Minify path:', minifyPath, '\n')

/* Here we have minify write the minified contents to another file: */
try {
  await minify.fileToFile('fileToMinify.js', 'fileToMinify.min.js')
} catch (error) {
  log('error:', error, '\n')
}

End of readme

Even though it's encapsulated in multiple layers of crap; 
know that inside of you there is pure love, because that's what you are!