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

unsafe-minifier

v0.1.0

Published

A command line minifier that morphs code to provide additional (unsafe) minification before standard minification.

Readme

Unsafe Minifier

Note: This is a prototype, the code quality and test coverage will significantly increase as I move away from the prototype.

Welcome to the world's first unsafe minifier (at least I think). Unlike traditional (safe) minifiers this minifier attempts to modify the flow of code but not the fundamental function of the code. It is important to note that due to the inclusion of AI, this minification technique will probably never be 100% accurate on choosing what should be minified. Although, over time I intend to get the accuracy about 90%. Finally, this minifer is intented to be used in combination with safe minification to provide levels of minification not possible by safe minification alone.

The code currently runs as a CLI accepting a file to be minified, outputting four files:

  • file_name.safe.min.js: File minified just by the traditional minifier (Uglify.js).
  • file_name.min.js: File unsafely minified.
  • file_name.full.min.js: File unsafely minified.

These four outputs should give a clear picture of the limits and potential of the current version of unsafe minification. Additonally, I have included a simple file in the top directory of the project demonstrating an optimal case of minification.

An analysis and summary of the decisions made can be found in Report.pdf.

Installation

These installation instructions are intended for a Debian based OS, though they should apply to most UNIX based OSs.

Automatic (Debian OS only):

  • Run: make install

Dependencies (automatically resolved with the automatic installer):

  • For NVM:
  • build-essential
  • libssl-dev
  • curl
  • git-core
  • For Node.js:
  • python
  • g++
  • make
  • For safe minification: UglifyJS (NPM module)

Manual:

  1. Install Node.js v0.8.2, not the latest as there is a problem with the node fann bindings library.
  • I suggest using nvm (Node Version Manager) to install Node.js.
  1. Install Uglify.js globally: npm install uglify-js -g
  2. Installing FANN (Fast Artificial Nueral Networks):
  1. If running "node main.js" results in an error, run 'ldconfig'. The exact command may vary based on OS.

Contact me at [email protected] if any of these steps don't work on your machine.

Structure Of The Application

Below is an explanation of the main files and directories in this directory. Details on specific directory structure can be found in respective READMEs.

Directories:

  • AST_modification: Code to transform ASTs, mostly function merging. Includes statistics generation.
  • data: where raw, transformed, and statistical data is contained.
  • generation: Code used to create data for that the training section trains on.
  • minification: Code used to minify a sent in file.
  • node_modules: Libraries that were used in my code are stored here.
  • training: Code to train and save the nueral networks.
  • tests: Tests for all the code, can be run from the top level with: make test-all

Files:

  • app.js: Central file that runs everything.
  • install.sh: Bash script that runs the installation process automatically.
  • Makefile Defines the commands to test this application.
  • messages.js: Central location of all error and console messages.
  • MIT_License: Document explaining this project's MIT license, nothing special added.
  • report.pdf: Report on why I made the choices I did and some of the data behind those choices. This is now becoming out of date as it was done at the start of the project.
  • simple_example.js: A two function file with 2 calls that can be minified, same example as in report.
  • simple_example.min.js: The simple example unsafely minified.
  • simple_example.full.min.js: The simple example unsafely minified and then safely minified.
  • simple_example.safe.min.js: The simple example just safely minified.
  • utility.js: A bunch of functions I wrote (except the custom array remove) for use in the entire program.

Testing

To run all tests: make test-all or make test-a

Debugging Tests: One debug listener for unit and integration tests

  1. Start the listener: make test-d or make test-debug
  2. Start the inspector: node-inspector
  3. Debug in Chrome: Go to the listed page in Chrome (and only Chrome), probably http://127.0.0.1:8080/debug?port=5858

Unit Tests: Covers all lower level code.

  • Run them once: make test or make test-u or make test-unit
  • Run them with every code change: make test-w or make test-watch

Integration Tests: Covers the three main sections of the code; data generation, machine learning, code minification.

  • Run them once: make test-i or make test-integration
  • Generator tests:
    • All files in data/raw_data ending in "test" will be used.
    • Test by writing two functions to be merged then specify what the result code should be:

function1 (a){ console.log(a); }
function2 (b){ return b * 2; }

function1('hello');
var b = function2(b);

/*test:
function double(a, b) {
{
  console.log(a);
}
return b * 2;
}
var b = double('hello', b);
*/

All parts of the code are to be tested although to different degrees. Low level code will have unit tests (in a behavioral style) like in the current utility_function.js tests. The test code is located in the test directory and is driven by the index.js file there. Tests are run by a Makefile which specifies mocha to test in a certian way.

Future

The goal is to upgrade the minifier to the point where it can correct choose above 90% of minifications and where it provides a minification bonus of 50%.

Short Term: Test and improve function finding in the AST analysis.

Contributions

Apart from unit tests for function finding in ASTs the project is fully tested so contributions are now welcome.