2.8.2 • Published 5 months ago

minify-selectors v2.8.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 months ago

Latest release version  Apache 2.0 license

minify-selectors

Post-processor that minifies class and ID selector names in CSS, HTML, Javascript and SVG files. minify-selectors aims to offer comprehensive out of the box support with minimal fuss.

Enhance your front-end assets and build optimisations pipeline — wring even more out from your already minified and optimised payload sizes. Additionally can offer a certain degree of obfuscation to your code.

What it can do

HTML and SVGs

CSS (and HTML embedded styles)

JS (and HTML embedded scripts)

Opt-in or opt-out of selector encoding

In cases where minify-selectors is unable to parse selectors, for example: in custom HTML attributes or JS variables. Or forcing a selector to be encoded when it otherwise would not be, such as in a HTML code element or comments. You can prefix your selector names so that minify-selectors knows to parse it and how to encode it:

  • .__-- or #__-- instead of the selector type ('#' or '.') before selector names
  • __class-- or __id-- for "name only" selectors, use '__class--' for class selectors and '__id--' for ID selectors

Or, you do not want minify-selectors to encode certain selectors (for reasons such as SEO). You can prefix your selector names so minify-selectors will leave the name as is (the prefix will be omitted):

  • .__ignore-- and #__ignore-- instead of the selector type ('#' or '.') before selector names
  • __ignore-- for selectors that are "name only"

How to use

Please note:

  • minify-selectors only supports regular CSS, HTML, JS and SVG files. SASS/SCSS, LESS, TypeScript, JQuery, Handlebars, etc. should be compiled or transpiled first into its respective vanilla form.
  • minify-selectors is currently limited to UTF-8 encoded files.

Via npm and npm scripts

  1. Install minify-selectors via npm:

    npm i minify-selectors
  2. Include minify-selectors in your package.json 'scripts' property, for example:

    "scripts": {
      "build": "npm run build:webpack && npm run build:minify-selectors",
      "build:minify-selectors": "minify-selectors --input \"example/dir/src/\" --output \"example/dir/dist/\"",
      "build:webpack": "webpack --config config/webpack-prod.config.js"
    },
  3. Run npm script command, for example:

    npm run build

Running as a CLI tool

  1. Install via homebrew:

    brew tap adamgian/minify-selectors && brew install minify-selectors
  2. Run in command line:

    minify-selectors --input "example/dir/src" --output "example/dir/dist"

Configuration

Command line options

External JSON config options

An example config file:

{
    "input": "/User/Adam/Github/project/dist",
    "output": "/User/Adam/Github/project/dist",
    "parallel": true,
    "customAttributes": {
        "id": [
            "data-bs-target",
            "data-bs-parent"
        ]
    }
}
2.8.1

6 months ago

2.8.1-alpha.20

6 months ago

2.8.1-alpha.21

6 months ago

2.8.1-alpha.22

6 months ago

2.6.3-alpha.27

6 months ago

2.6.3-alpha.26

6 months ago

2.8.2

5 months ago

2.6.3-alpha.21

6 months ago

2.6.3-alpha.20

6 months ago

2.6.3-alpha.23

6 months ago

2.6.3-alpha.22

6 months ago

2.6.2

1 year ago

2.6.2-alpha.6

1 year ago

2.8.1-alpha.8

1 year ago

2.8.1-alpha.7

1 year ago

2.8.1-alpha.6

1 year ago

2.8.1-alpha.4

1 year ago

2.8.1-alpha.5

1 year ago

2.8.1-alpha.1

1 year ago

2.8.1-alpha.2

1 year ago

2.8.1-alpha.3

1 year ago

2.8.1-alpha.0

1 year ago

2.6.1-alpha

1 year ago

2.6.0

1 year ago

2.4.1

2 years ago

2.4.0

2 years ago

2.1.3

2 years ago

2.3.3

2 years ago

2.0.0

2 years ago

1.0.0

3 years ago

1.7.2

3 years ago

1.6.2

3 years ago

1.6.2-beta.1

3 years ago

1.6.2-beta.0

3 years ago

1.9.4

3 years ago

1.9.2

3 years ago

1.10.1

3 years ago

1.10.0

3 years ago

1.0.0-beta.2

3 years ago

1.0.0-beta.3

3 years ago

1.0.0-beta.4

3 years ago

1.0.0-beta.1

3 years ago

0.9.15

3 years ago

0.11.0

3 years ago

0.11.3

3 years ago

0.9.8

3 years ago

0.7.8

3 years ago

0.4.4-alpha.0

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago