Download the PHP package premento/minify without Composer

On this page you can find all versions of the php package premento/minify. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package minify

Minify

Build status Code coverage Latest version Downloads total License

Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns, such as:

JavaScript

CSS

HTML

And it comes with a huge test suite.

Usage

CSS

JS

HTML

Whitespace in HTML is not like whitespace in CSS or JS: the space between two inline elements is rendered, so removing it changes the page. This minifier is therefore conservative by default - it collapses runs of whitespace into a single space, and only removes it completely next to block-level elements. <pre> and <textarea> content is left exactly as it was.

One caveat worth knowing: which elements count as block-level is decided from each element's default display, because that is all the markup tells us. CSS can change it, and then the minifier's assumption no longer holds:

If neither applies to your markup, the default settings leave the rendered page identical. See setAggressiveWhitespace() if you want to trade that for a few more bytes.

Methods

Available methods, for the CSS, JS & HTML minifiers, are:

__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.

add($path, / overload paths /)

This is roughly equivalent to the constructor.

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.

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.

gzip($path, $level)

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

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.

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.)

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

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.

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

The default embedded file types are gif, png, jpg, jpeg, svg, apng, avif, webp, woff and woff2.

setAggressiveWhitespace($aggressive) (HTML only)

By default, the HTML minifier only removes whitespace a browser wouldn't have rendered anyway. This method makes it remove all whitespace between tags, which is smaller, but also removes whitespace that is rendered:

Only turn this on if you know your markup doesn't rely on that spacing.

setMinifyInlineAssets($minify) (HTML only)

By default, the content of <style> and <script> elements is minified with this library's CSS and JS minifiers. Pass false to leave it untouched.

A <script> holding JSON rather than JavaScript - application/ld+json, application/json, importmap, speculationrules - is re-serialized instead, which drops its formatting without touching whitespace inside string values. Slashes stay escaped, so a <\/script> in a string can't break out of the element.

Content that is neither JavaScript nor JSON (inline templates, ...) is left alone. If minifying an inline asset fails, or JSON doesn't parse, the content is kept as-is rather than failing the whole document.

setBlockElements($elements) (HTML only)

The elements next to which whitespace is removed entirely rather than collapsed to a single space. The default list is derived from each element's default CSS display; override it when your stylesheet differs.

setVerbatimElements($elements) (HTML only)

The elements whose content is passed through untouched. Defaults to pre and textarea; add anything your CSS gives white-space: pre, since whitespace inside those is significant and the markup alone doesn't say so.

Installation

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

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

License

Minify is MIT licensed.


All versions of minify with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
ext-json Version *
ext-pcre Version *
matthiasmullie/path-converter Version ~1.1
psr/cache Version ^1.0 || ^2.0 || ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package premento/minify contains the following files

Loading the files please wait ...