2.20.19 • Published 2 months ago

@tdewolff/minify v2.20.19

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

JavaScript bindings for the Go minifiers for web formats minify, see github.com/tdewolff/minify.

Installation on Windows

THIS DOES NOT WORK UNFORTUNATELY

  • Install NPM
  • Install Python (optional?)
  • Open Windows Command Prompt and run:
  • $ npm install @tdewolff/minify

Build from source

  • Install Git
  • Install NPM
  • Install Python
  • Install Build Tools for Visual Studio under "Tools for Visual Studio". Make sure to also enable the "Desktop development with C++", see NodeJS - On Windows
  • Install TDM-GCC and select the 64+32 bit version, this is only to provide the mingw32-make binary
  • Install Go
  • Open the Git Bash and run:
  • $ git clone https://github.com/tdewolff/minify
  • $ cd minify/bindings/js
  • $ npm install

Usage

There are three functions available in JavaScript: configure the minifiers, minify a string, and minify a file. Below an example of their usage:

import { config, string, file } from '@tdewolff/minify';

# default config option values
config({
    'css-precision': 0,
    'html-keep-comments': false,
    'html-keep-conditional-comments': false,
    'html-keep-default-attr-vals': false,
    'html-keep-document-tags': false,
    'html-keep-end-tags': false,
    'html-keep-whitespace': false,
    'html-keep-quotes': false,
    'js-precision': 0,
    'js-keep-var-names': false,
    'js-version': 0,
    'json-precision': 0,
    'json-keep-numbers': false,
    'svg-keep-comments': false,
    'svg-precision': 0,
    'xml-keep-whitespace': false,
})

const s = string('text/html', '<span style="color:#ff0000;" class="text">Some  text</span>')
console.log(s)  // <span style=color:red class=text>Some text</span>

file('text/html', 'example.html', 'example.min.html')  // creates example.min.html

Mediatypes

The first argument is the mediatype of the content. The following mediatypes correspond to the configured minifiers:

  • text/css: CSS
  • text/html: HTML
  • image/svg+xml: SVG
  • (application|text)/(x-)?(java|ecma)script: JS
  • */json */*-json: JSON
  • */xml */*-xml: XML
2.20.19

2 months ago

2.20.18

3 months ago

2.20.17

3 months ago

2.20.16

3 months ago

2.20.15

3 months ago

2.20.14

4 months ago

2.20.13

4 months ago

2.20.12

4 months ago

2.20.11

4 months ago

2.20.10

5 months ago

2.20.8

5 months ago

2.20.9

5 months ago

2.20.6

6 months ago

2.20.7

6 months ago

2.20.4

6 months ago

2.20.5

6 months ago

2.20.3

6 months ago

2.12.5

1 year ago

2.12.3

2 years ago

2.12.4

2 years ago

2.12.1

2 years ago

2.12.2

2 years ago

2.12.0

2 years ago

2.11.16

2 years ago

2.11.15

2 years ago

2.11.14

2 years ago

2.11.13

2 years ago

2.11.12

2 years ago

2.11.11

2 years ago