minify-selectors v2.6.0
minify-selectors
Post-processor that minifies classes and IDs selector names in CSS, HTML and Javascript files. Each unique selector, and any subsequent occurances elsewhere, is converted into an ultracompact one.
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.
Features
For a full outline of capabilities and current limitations, see parse_selectors/info.md.
Comprehensive out of the box selector support
minify-selectors aims to minify all obvious selectors right out of the gate. Any extra work configuring should be to assist minify-selectors to identify additional and/or ambigious selectors.
CSS (or embedded style) example
JS (or embedded script) example
HTML example
Opt-in/opt-out selector encoding
Available in v1.0.0
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 CSS 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 CSS selector names__ignore--
— for selectors that are "name only"
Usage
Please note: minify-selectors only supports regular CSS, HTML and JS files. minify-selectors should be one of the final steps in your build process — SASS/SCSS, LESS, Typescript, JQuery, Handlebars, etc. should be compiled or transpiled first into its respective vanilla form.
Via npm and npm scripts
Install via npm:
npm i minify-selectors
Include minify-selectors in your package.json 'scripts' property:
"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" },
Run npm script command, for example:
npm run build
Running as CLI tool
Install via homebrew:
brew tap adamgian/minify-selectors && brew install minify-selectors
Run in command line:
minify-selectors --input "example/dir/src" --output "example/dir/dist"
Options
2 days ago
1 month ago
2 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago