2017 © Pedro Peláez
 

library minify

CSS & JS minifier

image

intelogie/minify

CSS & JS minifier

  • Friday, December 9, 2016
  • by bgauthier
  • Repository
  • 1 Watchers
  • 0 Stars
  • 47 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 182 Forks
  • 0 Open issues
  • 50 Versions
  • 9 % Grown

The README.md

Minify

Build status Code coverage Code quality Latest version Downloads total License, (*1)

Usage

CSS

use MatthiasMullie\Minify;

$sourcePath = '/path/to/source/css/file.css';
$minifier = new Minify\CSS($sourcePath);

// we can even add another file, they'll then be
// joined in 1 output file
$sourcePath2 = '/path/to/second/source/css/file.css';
$minifier->add($sourcePath2);

// or we can just add plain CSS
$css = 'body { color: #000000; }';
$minifier->add($css);

// save minified file to disk
$minifiedPath = '/path/to/minified/css/file.css';
$minifier->minify($minifiedPath);

// or just output the content
echo $minifier->minify();

JS

// just look at the CSS example; it's exactly the same, but with the JS class & JS files :)

Methods

Available methods, for both CSS & JS minifier, are:, (*2)

__construct(/* overload paths */)

The object constructor accepts 0, 1 or multiple paths of files, or even complete CSS/JS content, that should be minified. All CSS/JS passed along, will be combined into 1 minified file., (*3)

use MatthiasMullie\Minify;
$minifier = new Minify\JS($path1, $path2);

add($path, /* overload paths */)

This is roughly equivalent to the constructor., (*4)

$minifier->add($path3);
$minifier->add($js);

minify($path)

This will minify the files' content, save the result to $path and return the resulting content. If the $path parameter is omitted, the result will not be written anywhere., (*5)

CAUTION: If you have CSS with relative paths (to imports, images, ...), you should always specify a target path! Then those relative paths will be adjusted in accordance with the new path., (*6)

$minifier->minify('/target/path.js');

gzip($path, $level)

Minifies and optionally saves to a file, just like minify(), but it also gzencode()s the minified content., (*7)

$minifier->gzip('/target/path.js');

setMaxImportSize($size) (CSS only)

The CSS minifier will automatically embed referenced files (like images, fonts, ...) into the minified CSS, so they don't have to be fetched over multiple connections., (*8)

However, for really large files, it's likely better to load them separately (as it would increase the CSS load time if they were included.), (*9)

This method allows the max size of files to import into the minified CSS to be set (in kB). The default size is 5., (*10)

$minifier->setMaxImportSize(10);

setImportExtensions($extensions) (CSS only)

The CSS minifier will automatically embed referenced files (like images, fonts, ...) into minified CSS, so they don't have to be fetched over multiple connections., (*11)

This methods allows the type of files to be specified, along with their data:mime type., (*12)

The default embedded file types are gif, png, jpg, jpeg, svg & woff., (*13)

$extensions = array(
    'gif' => 'data:image/gif',
    'png' => 'data:image/png',
);

$minifier->setImportExtensions($extensions);

Installation

Simply add a dependency on matthiasmullie/minify to your composer.json file if you use Composer to manage the dependencies of your project:, (*14)

composer require matthiasmullie/minify

Although it's recommended to use Composer, you can actually include these files anyway you want., (*15)

Try it

Simply try it out online at http://www.minifier.org., (*16)

License

Minify is MIT licensed., (*17)

Challenges

If you're interested in learning some of the harder technical challenges I've encountered building this, you probably want to take a look at what I wrote about it on my blog., (*18)

The Versions

09/12 2016

dev-master

9999999-dev http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

23/11 2016

1.3.42

1.3.42.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

11/11 2016

1.3.41

1.3.41.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

10/11 2016

1.3.40

1.3.40.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

28/10 2016

1.3.39

1.3.39.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

13/10 2016

1.3.38

1.3.38.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

20/09 2016

1.3.37

1.3.37.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

14/09 2016

1.3.36

1.3.36.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

09/06 2016

1.3.35

1.3.35.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

01/03 2016

1.3.34

1.3.34.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

17/02 2016

1.3.33

1.3.33.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

11/01 2016

1.3.32

1.3.32.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

07/01 2016

1.3.31

1.3.31.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

05/01 2016

1.3.30

1.3.30.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

17/12 2015

1.3.29

1.3.29.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

20/08 2015

1.3.28

1.3.28.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

29/06 2015

1.3.27

1.3.27.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

29/06 2015

dev-refactor

dev-refactor http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

13/05 2015

1.3.26

1.3.26.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

05/05 2015

1.3.25

1.3.25.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

07/04 2015

1.3.24

1.3.24.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

12/03 2015

1.3.23

1.3.23.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

10/03 2015

1.3.22

1.3.22.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

06/03 2015

1.3.21

1.3.21.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

02/03 2015

1.3.20

1.3.20.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

26/02 2015

1.3.19

1.3.19.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

 

The Development Requires

css javascript minifier js minify

06/02 2015

1.3.18

1.3.18.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

03/02 2015

1.3.17

1.3.17.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

03/02 2015

1.3.16

1.3.16.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

23/01 2015

1.3.15

1.3.15.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

11/01 2015

1.3.14

1.3.14.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

09/01 2015

1.3.13

1.3.13.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

07/01 2015

1.3.12

1.3.12.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

30/12 2014

1.3.11

1.3.11.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

07/12 2014

1.3.10

1.3.10.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

05/12 2014

1.3.9

1.3.9.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

20/11 2014

1.3.8

1.3.8.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

30/10 2014

1.3.7

1.3.7.0 http://www.minifier.org

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

20/10 2014

1.3.6

1.3.6.0 https://github.com/matthiasmullie/minify

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

14/10 2014

1.3.5

1.3.5.0 https://github.com/matthiasmullie/minify

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

11/10 2014

1.3.4

1.3.4.0 https://github.com/matthiasmullie/minify

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

10/10 2014

1.3.3

1.3.3.0 https://github.com/matthiasmullie/minify

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

09/10 2014

1.3.2

1.3.2.0 https://github.com/matthiasmullie/minify

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

The Development Requires

08/10 2014

1.3.1

1.3.1.0 https://github.com/matthiasmullie/minify

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

08/10 2014

1.3.0

1.3.0.0 https://github.com/matthiasmullie/minify

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

01/12 2013

1.2.0

1.2.0.0 https://github.com/matthiasmullie/minify

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

22/04 2013

1.1.2

1.1.2.0 https://github.com/matthiasmullie/minify

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

15/04 2013

1.1.1

1.1.1.0 https://github.com/matthiasmullie/minify

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

14/04 2013

1.1.0

1.1.0.0 https://github.com/matthiasmullie/minify

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.3.0

 

19/10 2012

1.0.0

1.0.0.0 https://github.com/matthiasmullie/minify

CSS & JS minifier

  Sources   Download

MIT

The Requires

  • ext-pcre *
  • php >=5.2.0