🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

uncss

Package Overview
Dependencies
Maintainers
2
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uncss

Remove unused CSS styles

0.17.3
latest
Source
npm
Version published
Weekly downloads
197K
27.36%
Maintainers
2
Weekly downloads
 
Created

What is uncss?

The 'uncss' npm package is a tool used to remove unused CSS from your stylesheets. It analyzes your HTML files to determine which CSS selectors are actually used and removes the unused ones, resulting in smaller and more efficient CSS files.

What are uncss's main functionalities?

Remove Unused CSS

This feature allows you to remove unused CSS from your stylesheets by analyzing the HTML files you provide. The code sample demonstrates how to use the 'uncss' package to process a single HTML file and output the cleaned CSS.

const uncss = require('uncss');

const files = ['myPage.html'];

uncss(files, (error, output) => {
  console.log(output);
});

Process Multiple Files

You can process multiple HTML files at once to remove unused CSS. This is useful for projects with multiple pages. The code sample shows how to pass an array of HTML files to 'uncss' and receive the cleaned CSS output.

const uncss = require('uncss');

const files = ['page1.html', 'page2.html'];

uncss(files, (error, output) => {
  console.log(output);
});

Use with Options

The 'uncss' package allows you to specify options such as ignoring certain selectors or handling specific media queries. The code sample demonstrates how to use these options to customize the CSS cleaning process.

const uncss = require('uncss');

const files = ['index.html'];
const options = {
  ignore: ['#ignored-id', '.ignored-class'],
  media: ['(min-width: 700px) handheld and (orientation: landscape)']
};

uncss(files, options, (error, output) => {
  console.log(output);
});

Other packages similar to uncss

Keywords

optimize

FAQs

Package last updated on 11 Feb 2020

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