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

rmrf-css

v1.0.5

Published

A lean and thorough npm package for trimming unused CSS from CSS files based on the selectors matched in provided HTML files

Downloads

353

Readme

rmrf-css

A much leaner and quicker npm package for trimming unused CSS from CSS files based on the selectors matched in provided HTML files

Getting Started

Browser-based

Head over to https://rmrf-css.vercel.app for a more comprehensive, simple, UI-based trimming and downloading of used styles for your provided website URL.


Via the command line

  • Clone the repository
git clone https://github.com/ogbotemi-2000/rmrf-css.git
  • Or install the package locally via npm
npm install rmrf-css

Both options above are quick and direct - the package has zero dependencies, no npm install required

Usage

The browser-based version is direct and progressive with short texts when necessary to guide its usage.

The section below comprises guides for using the package programatically

As a module

const rem_css = require('rmrf-css');

rem_css({
  html: /* array of html filenames or a filename */,
  css:  /* array of css filenames or a filename */
  out: /* output directory for the trimmed css files */

})

/* defaults to {html:'./', css:'css', out:'dist'}.
 * the output directory is created if it does not exist
 */
rem_css()

Via invocation from the command-line

  • Via npm run <script> <arguments>

Include the code block below in your package.json file for it to work

...
  "scripts": {
    ...
    "rmrf-css": "node ./node_modules/rmrf-css/index"
    ...
  }
...

It is invoked as

npm run rmrf-css -- -html <html file names or folder path> -css <similar but for css> -out <output folder>

An example - npm run rmrf-css -- -h 'index.html, sitemap.html' -c public/css -o dist, the double dashes are required for proper behaviour

  • Via node path/to/rmrf-css/index
node path/to/rmrf-css/index -h index.html -c 'tailwind.css, all.css' -o output-folder

The arguments can also be provided in the long version

node path/to/rmrf-css/index.js --html 'index.html, 404.html' --css 'tailwind.css, all.css' -output output-folder

The arguments above can be anything, what matters is that their initial letters - 'h', 'c', 'o' as speciified in the index.js file remain in the same position:


... argv(['-h', '-c', '-o'], ['./', 'css', 'dist']) ...

Awareness

  1. The code warns with a message when it takes over 6000ms when boosting the trimming operation. This happens when the number of unique selectors to be audited is great and it is done to avoid long-running behaviour that produces unwanted results. If such edge case happens and it seems to be inconvenient to you, please discuss the workarounds it suggests here

  2. Such a workaround for the edge case mentioned above will involve breaking the detected unique selectors into smaller chunks and invoking the scripts directly thereof with the last provided arguments used.

  3. Modifying the performance threshold time of 6000ms or the "boost" mentioned above may follow this proprotion:

[Defaults] 500,000 bytes per cycle as boost  ≡  (Should take at most 6000ms)
<New bytes per run via for loop> 	           ≡  <New threshold time>

Assume any value you want for either unknown above and cross-multiply, solve to obtain other unknown

License

Distributed under the EPUL License. See 'LICENSE.txt' for more information

Copyright © 2024 Ogbotemi Akin Ogungbamila

Discuss

Discussions are welcome!

Contact

Ogbotemi Akin Ogungbamila

Acknowledgements