PHPackages                             patchwork/jsqueeze - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. patchwork/jsqueeze

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

patchwork/jsqueeze
==================

Efficient JavaScript minification in PHP

v2.0.5(10y ago)1585.8M↓14.3%36[10 issues](https://github.com/tchwork/jsqueeze/issues)20(Apache-2.0 or GPL-2.0)PHPPHP &gt;=5.3.0

Since Jan 28Pushed 6y ago20 watchersCompare

[ Source](https://github.com/tchwork/jsqueeze)[ Packagist](https://packagist.org/packages/patchwork/jsqueeze)[ Docs](https://github.com/tchwork/jsqueeze)[ RSS](/packages/patchwork-jsqueeze/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (14)Used By (20)

JSqueeze: Efficient JavaScript minification in PHP
==================================================

[](#jsqueeze-efficient-javascript-minification-in-php)

[![Latest Stable Version](https://camo.githubusercontent.com/df853fb92668f2c8d7218c8fddb4d86728b87f9e3ae57804739d96731da4da9d/68747470733a2f2f706f7365722e707567782e6f72672f7061746368776f726b2f6a73717565657a652f762f737461626c652e706e67)](https://packagist.org/packages/patchwork/jsqueeze)[![Total Downloads](https://camo.githubusercontent.com/1727c62621e0b950a5c534f86d1b324ae03efc9332dfce9bd08ad5b884f07430/68747470733a2f2f706f7365722e707567782e6f72672f7061746368776f726b2f6a73717565657a652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/patchwork/jsqueeze)[![Build Status](https://camo.githubusercontent.com/de647e636056fcd659197cba60ae27ada2d07fc2f3ce2c91ffe418fda664a71e/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f746368776f726b2f6a73717565657a652e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/tchwork/jsqueeze)

JSqueeze shrinks / compresses / minifies / mangles Javascript code.

It's a single PHP class that has been developed, maintained and thoroughly tested since 2003 on major JavaScript frameworks (e.g. jQuery).

JSqueeze operates on any parse error free JavaScript code, even when semi-colons are missing.

In term of compression ratio, it compares to YUI Compressor and UglifyJS.

Installation
------------

[](#installation)

Through [composer](https://getcomposer.org/):

```
{
    "require": {
        "patchwork/jsqueeze": "~2.0"
    }
}
```

Usage
-----

[](#usage)

```
use Patchwork\JSqueeze;

$jz = new JSqueeze();

$minifiedJs = $jz->squeeze(
    $fatJs,
    true,   // $singleLine
    true,   // $keepImportantComments
    false   // $specialVarRx
);
```

Features
--------

[](#features)

- Removes comments and white spaces.
- Renames every local vars, typically to a single character.
- Keep Microsoft's conditional comments.
- In order to maximise later HTTP compression (deflate, gzip), new variables names are choosen by considering closures, variables' frequency and characters' frequency.
- Can rename also global vars, methods and properties, but only if they are marked special by some naming convention. Use JSqueeze::SPECIAL\_VAR\_PACKER to rename vars whose name begins with one or more `$` or with a single `_`.
- Renames also local/global vars found in strings, but only if they are marked special.
- If you use `with/eval` then be careful.

Bonus
-----

[](#bonus)

- Replaces `false/true` by `!1/!0`
- Replaces `new Array/Object` by `[]/{}`
- Merges consecutive `var` declarations with commas
- Merges consecutive concatened strings
- Can replace optional semi-colons by line feeds, thus facilitating output debugging.
- Keep important comments marked with `/*!...`
- Treats three semi-colons `;;;` [like single-line comments](http://dean.edwards.name/packer/2/usage/#triple-semi-colon).
- Fix special catch scope across browsers
- Work around buggy-handling of named function expressions in IE&lt;=8

To do?
------

[](#to-do)

- foo\['bar'\] =&gt; foo.bar
- {'foo':'bar'} =&gt; {foo:'bar'}
- Dead code removal (never used function)
- Munge primitives: var WINDOW=window, etc.

License
-------

[](#license)

This library is free software; you can redistribute it and/or modify it under the terms of the (at your option): Apache License v2.0 (see provided LICENCE.ASL20 file), or GNU General Public License v2.0 (see provided LICENCE.GPLv2 file).

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity60

Solid adoption and visibility

Community38

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 97% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~67 days

Recently: every ~98 days

Total

13

Last Release

3682d ago

Major Versions

v1.0.6 → v2.0.02015-01-01

v1.0.7 → v2.0.32015-08-20

PHP version history (2 changes)v1.0PHP &gt;=5.1.4

v2.0.0PHP &gt;=5.3.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/243674?v=4)[Nicolas Grekas](/maintainers/nicolas-grekas)[@nicolas-grekas](https://github.com/nicolas-grekas)

---

Top Contributors

[![nicolas-grekas](https://avatars.githubusercontent.com/u/243674?v=4)](https://github.com/nicolas-grekas "nicolas-grekas (160 commits)")[![0b10011](https://avatars.githubusercontent.com/u/1123348?v=4)](https://github.com/0b10011 "0b10011 (1 commits)")[![AdamWill](https://avatars.githubusercontent.com/u/916551?v=4)](https://github.com/AdamWill "AdamWill (1 commits)")[![callmemagnus](https://avatars.githubusercontent.com/u/232478?v=4)](https://github.com/callmemagnus "callmemagnus (1 commits)")[![stchr](https://avatars.githubusercontent.com/u/166079?v=4)](https://github.com/stchr "stchr (1 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (1 commits)")

---

Tags

javascriptcompressionminification

### Embed Badge

![Health badge](/badges/patchwork-jsqueeze/health.svg)

```
[![Health](https://phpackages.com/badges/patchwork-jsqueeze/health.svg)](https://phpackages.com/packages/patchwork-jsqueeze)
```

###  Alternatives

[kriswallsmith/assetic

Asset Management for PHP

3.7k48.9M161](/packages/kriswallsmith-assetic)[assetic/framework

Asset Management for PHP

1001.4M20](/packages/assetic-framework)[tholu/php-packer

A PHP version of Packer, JavaScript obfuscation library originally created by Dean Edwards

137441.2k5](/packages/tholu-php-packer)[mmanos/laravel-casset

An asset management package for Laravel 4.

102.6k](/packages/mmanos-laravel-casset)[toopay/assetic-minifier

Assetic Filter for pure PHP JS and CSS minification

1356.8k3](/packages/toopay-assetic-minifier)[konstantin-kuklin/assetic-static-gzip-bundle

Provide static gzip compression for css,js files via AsseticBundle

149.2k1](/packages/konstantin-kuklin-assetic-static-gzip-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
