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.7.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 in CSS, HTML and Javascript files.

Each unique identifier is assigned an index which is converted into an ultra compact CSS valid selector.

Examples

CSS (source):

#page--default { … }
.sidebar, .site-nav { … }
.sidebar .search:focus-within { … }
.sidebar--expanded a.is-active { … }

CSS (output):

#a { … }
.b, .c { … }
.b .d:focus-within { … }
.e a.d { … }

HTML (source):

<main 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>
</main>

HTML (output):

<main 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>
</main>

JS (source)

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

JS (output)

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

Usage

Install from npm

npm i minify-selectors

Run within npm scripts or in command line

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

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 processed first.

Options

CLI flags

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.

Keywords

FAQs

Package last updated on 23 Apr 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