Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clean-css

Package Overview
Dependencies
Maintainers
1
Versions
211
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clean-css

A well-tested CSS minifier

  • 1.0.12
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14M
decreased by-8.97%
Maintainers
1
Weekly downloads
 
Created

What is clean-css?

clean-css is a fast and efficient CSS optimizer for Node.js and the web. It minifies CSS by removing whitespace, comments, and unnecessary characters, merging identical rules, and applying other optimization techniques. It can be used to reduce the size of CSS files, which can lead to faster page load times and improved performance.

What are clean-css's main functionalities?

Minification

This feature allows you to minify CSS by removing unnecessary characters and whitespace, which results in smaller file sizes.

const CleanCSS = require('clean-css');
new CleanCSS().minify('a { font-weight: bold; }', function (error, output) {
  console.log(output.styles);
});

Source Map Generation

clean-css can generate source maps for the minified CSS, which is useful for debugging minified code in the browser.

const CleanCSS = require('clean-css');
new CleanCSS({ sourceMap: true, sourceMapInlineSources: true }).minify({ 'styles.css': { styles: 'a { color: #000 }' } }, function (error, output) {
  console.log(output.sourceMap.toString());
});

Merging of Identical CSS Rules

This feature merges identical CSS rules into one to reduce file size and redundancy in the code.

const CleanCSS = require('clean-css');
new CleanCSS().minify('a { color: red; } a { color: red; }', function (error, output) {
  console.log(output.styles);
});

Optimizing CSS Properties

clean-css can optimize CSS properties, such as converting hex color codes to shorter names when possible.

const CleanCSS = require('clean-css');
new CleanCSS().minify('a { color: #FF0000; }', function (error, output) {
  console.log(output.styles);
});

Other packages similar to clean-css

Keywords

FAQs

Package last updated on 19 Jul 2013

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