npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

minify-selectors

v2.6.2

Published

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

Downloads

24

Readme

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"
        ]
    }
}