8000 GitHub - jablonczay/minify at 1.3.0 · GitHub
[go: up one dir, main page]

Skip to content
  • jablonczayPublic

    About

    CSS & JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns.

    Resources

    Stars

    0 stars

    Watchers

    0 watching

    Forks

    Latest commit

     

    History

    23 Commits

    Folders and files

    Repository files navigation

    Minify

    Methods

    Available methods, for both CSS & JS minifier, are:

    __construct(/* overload paths */)

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

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

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

    This is roughly equivalent to the constructor.

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

    minify($path, $options)

    This will minify the files' content, save the result to $path and return the resulting content. If the $path parameter is false, the result will not be written anywhere. CAUTION: Only use this for "simple" CSS: if no target directory ($path) is known, relative uris to e.g. images can not be fixed!

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

    Example usage

    $file1 = '/path/to/file1.css';
    $file2 = '/yet/another/path/to/file2.css';
    $file3 = '/and/another/path/to/file3.css';
    $css = 'body { color: #000000; }';
    
    // constructor can be overloaded with multiple files
    $minifier = new Minify\CSS($file1, $file2);
    
    // or files can be added individually
    $minifier->add($file3);
    
    // or even css content can be loaded
    $minifier->add($css);
    
    // minify & write to file
    $minifier->minify('/target/path.css');
    

    License

    Minify is 56F7 MIT licensed.

    CLI script

    Baki Goxhaj developed a CLI tool using this library - could be useful to automate minification of your project's CSS/JS files in e.g. some build or deployment script.

    About

    CSS & JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns.

    Resources

    Stars

    0 stars

    Watchers

    0 watching

    Forks

    Releases

    Packages

    Contributors

    Languages

    0