New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

minify-selectors

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minify-selectors

Post-processor that minifies classes and IDs in CSS, HTML and Javascript files.

  • 0.9.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

minify-selectors

Post-processor that minifies classes and IDs selector names in CSS, HTML and Javascript files. Each unique identifier — and any subsequent occurances — is converted to an ultracompact CSS valid selector name.

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.

Examples

CSS

[id='page--default'] { … }
.sidebar, .site-nav { … }
.sidebar .search:focus-within { … }
.sidebar--expanded a.is-active { … }
[id='a'], { … }
.b, .c { … }
.b .d:focus-within { … }
.e a.d { … }

HTML

<body id="page--default">
    <nav class="site-nav">
        <div class="search has-content">
            <label for="site-search" class="text--muted text--center"></label>
            <input type="text" id="site-search" class="form-input--single form-input--lg border--thick">
        </div>
    </nav>
</body>
<body id="a">
    <nav class="c">
        <div class="d a1">
            <label for="y" class="F j"></label>
            <input type="text" id="y" class="A9 t Av">
        </div>
    </nav>
</body>

JS

for (let link of document.querySelectorAll('a.anchor')) {
    link.classList.remove('is-active');
}
for (let link of document.querySelectorAll('a.Bd')) {
    link.classList.remove('d');
}

For a full outline of capabilities and current limitations, see parse_selectors/info.md

Usage

CLI

  1. Install from npm:

    npm i -g minify-selectors
    
  2. Run in command line:

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

npm scripts

  1. Install from npm:

    npm i minify-selectors
    
  2. Include minify-selectors in your package.json scripts:

    "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:

    npm run build
    

Options

FlagDescription
--input (or -i)Directory or file to process. If a directory path is provided — any CSS, HTML and JS files in the given directory and sub-directories will be parsed. If only a filepath is provided — only the given file will be parsed.
--output (or -o)Directory to ouput processed files to. Setting the output path to be the same as the input path will overwrite existing files.
--alphabetCustom sequence of characters to use when encoding.

By default, selector names will be encoded using the following base 62 string: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
--start-indexIndex to start incrementing and encoding from.

By default, this will begin from 0 (essentially a if using the default alphabet).

Keywords

FAQs

Package last updated on 13 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc