minify

WebJar for minify

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

minify
Последняя версия

Последняя версия

4.1.3
Дата

Дата

Тип

Тип

jar
Описание

Описание

minify
WebJar for minify
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/coderaiser/minify

Скачать minify

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/minify/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>minify</artifactId>
    <version>4.1.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/minify/
implementation 'org.webjars.npm:minify:4.1.3'
// https://jarcasting.com/artifacts/org.webjars.npm/minify/
implementation ("org.webjars.npm:minify:4.1.3")
'org.webjars.npm:minify:jar:4.1.3'
<dependency org="org.webjars.npm" name="minify" rev="4.1.3">
  <artifact name="minify" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='minify', version='4.1.3')
)
libraryDependencies += "org.webjars.npm" % "minify" % "4.1.3"
[org.webjars.npm/minify "4.1.3"]

Зависимости

compile (7)

Идентификатор библиотеки Тип Версия
org.webjars.npm : try-to-catch jar [1.0.2,2)
org.webjars.npm : css-b64-images jar [0.2.5,0.3)
org.webjars.npm : try-catch jar [2.0.0,3)
org.webjars.npm : clean-css jar [4.1.6,5)
org.webjars.npm : debug jar [4.1.0,5)
org.webjars.npm : html-minifier jar [4.0.0,5)
org.webjars.npm : terser jar [4.0.0,5)

Модули Проекта

Данный проект не имеет модулей.

Minify License Dependency Status Build Status NPM version

Minify - a minifier of js, css, html and img files. To use minify as middleware try Mollify.

Install

npm i minify -g

How to use?

CLI

The bash command below creates a code snippet saved as "hello.js".

Simply copy + paste the code starting with cat, including the EOT on the last line, and press .

$ cat << EOT > hello.js
const hello = 'world';

for (let i = 0; i < hello.length; i++) {
    console.log(hello[i]);
}
EOT

Use the command minify followed by the path to and name of the js file intended to be minified. This will minify the code and output it to the screen.

$ minify hello.js
const hello="world";for(let l=0;l<hello.length;l++)console.log(hello[l]);

You can capture the output with the following:

$ minify hello.js > hello.min.js

Code Example

minify can be used as a promise:

const minify = require('minify');
const options = {
    html: {
        removeAttributeQuotes: false,
        removeOptionalTags: false
    },
};

minify('./client.js', options)
    .then(console.log)
    .catch(console.error);

Or with async-await and try-to-catch:

const minify = require('minify');
const tryToCatch = require('try-to-catch');
const options = {
    html: {
        removeAttributeQuotes: false,
        removeOptionalTags: false
    }
};

async () => {
    const [error, data] = await tryToCatch(minify, './client.js', options);
    
    if (error)
        return console.error(error.message);
    
    console.log(data);
}();

Options

The options object accepts configuration for html, css, js, and img like so:

const options = {
    html: {
        removeAttributeQuotes: false,
    },
    css: {
        compatibility: '*',
    },
    js: {
        ecma: 5,
    },
    img: {
        maxSize: 4096,
    }
}

Full documentation for options that each file type accepts can be found on the pages of the libraries used by minify to process the files:

Minify sets a few defaults for HTML that may differ from the base html-minifier settings:

  • removeComments: true
  • removeCommentsFromCDATA: true
  • removeCDATASectionsFromCDATA: true
  • collapseWhitespace: true
  • collapseBooleanAttributes: true
  • removeAttributeQuotes: true
  • removeRedundantAttributes: true
  • useShortDoctype: true
  • removeEmptyAttributes: true
  • removeEmptyElements: false
  • removeOptionalTags: true
  • removeScriptTypeAttributes: true
  • removeStyleLinkTypeAttributes: true
  • minifyJS: true
  • minifyCSS: true

License

MIT

Версии библиотеки

Версия
4.1.3