2017 © Pedro Peláez
 

library jsqueeze

Efficient JavaScript minification in PHP

image

patchwork/jsqueeze

Efficient JavaScript minification in PHP

  • Tuesday, April 19, 2016
  • by nicolas-grekas
  • Repository
  • 21 Watchers
  • 123 Stars
  • 1,222,264 Installations
  • PHP
  • 88 Dependents
  • 13 Suggesters
  • 25 Forks
  • 16 Open issues
  • 14 Versions
  • 15 % Grown

The README.md

Latest Stable Version Total Downloads Build Status, (*1)

JSqueeze shrinks / compresses / minifies / mangles Javascript code., (*2)

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

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

In term of compression ratio, it compares to YUI Compressor and UglifyJS., (*5)

Installation

Through composer:, (*6)

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

Usage


use Patchwork\JSqueeze; $jz = new JSqueeze(); $minifiedJs = $jz->squeeze( $fatJs, true, // $singleLine true, // $keepImportantComments false // $specialVarRx );

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

  • 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.
  • Fix special catch scope across browsers
  • Work around buggy-handling of named function expressions in IE<=8

To do?

  • foo['bar'] => foo.bar
  • {'foo':'bar'} => {foo:'bar'}
  • Dead code removal (never used function)
  • Munge primitives: var WINDOW=window, etc.

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)., (*7)

The Versions

19/04 2016

dev-master

9999999-dev https://github.com/tchwork/jsqueeze

Efficient JavaScript minification in PHP

  Sources   Download

(Apache-2.0 or GPL-2.0)

The Requires

  • php >=5.3.0

 

javascript compression minification

19/04 2016

v2.0.5

2.0.5.0 https://github.com/tchwork/jsqueeze

Efficient JavaScript minification in PHP

  Sources   Download

(Apache-2.0 or GPL-2.0)

The Requires

  • php >=5.3.0

 

javascript compression minification

27/03 2016

v2.0.4

2.0.4.0 https://github.com/tchwork/jsqueeze

Efficient JavaScript minification in PHP

  Sources   Download

(Apache-2.0 or GPL-2.0)

The Requires

  • php >=5.3.0

 

javascript compression minification

20/08 2015

v2.0.3

2.0.3.0 https://github.com/tchwork/jsqueeze

Efficient JavaScript minification in PHP

  Sources   Download

(Apache-2.0 or GPL-2.0)

The Requires

  • php >=5.3.0

 

javascript compression minification

25/03 2015

v1.0.7

1.0.7.0 https://github.com/tchwork/jsqueeze

Efficient JavaScript minification in PHP

  Sources   Download

(Apache-2.0 or GPL-2.0)

The Requires

  • php >=5.1.4

 

javascript compression minification

23/03 2015

v2.0.2

2.0.2.0 https://github.com/tchwork/jsqueeze

Efficient JavaScript minification in PHP

  Sources   Download

(Apache-2.0 or GPL-2.0)

The Requires

  • php >=5.3.0

 

javascript compression minification

01/01 2015

v2.0.1

2.0.1.0 https://github.com/tchwork/jsqueeze

Efficient JavaScript minification in PHP

  Sources   Download

(Apache-2.0 or GPL-2.0)

The Requires

  • php >=5.3.0

 

javascript compression minification

01/01 2015

v2.0.0

2.0.0.0 https://github.com/tchwork/jsqueeze

Efficient JavaScript minification in PHP

  Sources   Download

(Apache-2.0 or GPL-2.0)

The Requires

  • php >=5.3.0

 

javascript compression minification

01/01 2015

v1.0.6

1.0.6.0 https://github.com/tchwork/jsqueeze

Efficient JavaScript minification in PHP

  Sources   Download

(Apache-2.0 or GPL-2.0)

The Requires

  • php >=5.1.4

 

javascript compression minification

08/11 2014

v1.0.5

1.0.5.0 https://github.com/tchwork/jsqueeze

Efficient JavaScript minification in PHP

  Sources   Download

(Apache-2.0 or GPL-2.0)

The Requires

  • php >=5.1.4

 

javascript compression minification

07/11 2014

v1.0.4

1.0.4.0 https://github.com/tchwork/jsqueeze

Efficient JavaScript minification in PHP

  Sources   Download

(Apache-2.0 or GPL-2.0)

The Requires

  • php >=5.1.4

 

javascript compression minification

07/11 2014

v1.0.3

1.0.3.0 https://github.com/tchwork/jsqueeze

Efficient JavaScript minification in PHP

  Sources   Download

(Apache-2.0 or GPL-2.0)

The Requires

  • php >=5.1.4

 

javascript compression minification

05/08 2014

v1.0.1

1.0.1.0 https://github.com/nicolas-grekas/JSqueeze

Efficient JavaScript minification in PHP

  Sources   Download

(Apache-2.0 or GPL-2.0)

The Requires

  • php >=5.1.4

 

javascript compression minification

28/01 2014

v1.0

1.0.0.0 https://github.com/nicolas-grekas/JSqueeze

Efficient JavaScript minification in PHP

  Sources   Download

(Apache-2.0 or GPL-2.0)

The Requires

  • php >=5.1.4

 

javascript compression minification