New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

uncss

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uncss - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

2

bin/index.js

@@ -32,2 +32,2 @@ #!/usr/bin/env node

uncss(css_files, html_files, options);
console.log(uncss(css_files, html_files, options));

@@ -35,44 +35,43 @@ /*jslint node: true, plusplus: true */

*/
var used_rules = parsed_css.stylesheet.rules.map(function (rule) {
/* This is the syntax of css-parse
* rule = {
* "selectors": [ ... ],
* "declarations": [ ... ]
* }
*
*/
if (rule.selectors) {
var used_selectors = rule.selectors.filter(function (selector) {
return (soupselect(dom, selector).length > 0);
});
/* Case 1:
* rule = {
* "selectors": ['a', 'c'],
var i,
uncss = '',
used_rules = parsed_css.stylesheet.rules.map(function (rule) {
/* This is the syntax of css-parse
* rule = {
* "selectors": [ ... ],
* "declarations": [ ... ]
* }
*
* Case 2:
* rule = {
* "selectors": [],
* "declarations": [ ... ]
* }
*
*/
if (used_selectors.length > 0) {
/* Case 1 */
return {
'selectors': used_selectors,
'declarations': rule.declarations
};
if (rule.selectors) {
var used_selectors = rule.selectors.filter(function (selector) {
return (soupselect(dom, selector).length > 0);
});
/* Case 1:
* rule = {
* "selectors": ['a', 'c'],
* "declarations": [ ... ]
* }
*
* Case 2:
* rule = {
* "selectors": [],
* "declarations": [ ... ]
* }
*/
if (used_selectors.length > 0) {
/* Case 1 */
return {
'selectors': used_selectors,
'declarations': rule.declarations
};
}
}
}
/* Case 2, or rule isn't a selector array (for example, a comment) */
return {};
/* Case 2, or rule isn't a selector array (for example, a comment) */
return {};
}).filter(function (rule) {
return rule.selectors !== undefined;
}),
uncss = '',
i;
}).filter(function (rule) {
return rule.selectors !== undefined;
});
for (i = 0; i < used_rules.length; i++) {

@@ -96,3 +95,3 @@ uncss += used_rules[i].selectors.join(', ')

} else {
console.log(uncss);
return uncss;
}

@@ -99,0 +98,0 @@ }

{
"name": "uncss",
"version": "0.1.1",
"version": "0.1.2",
"description": "Remove unused CSS styles",

@@ -5,0 +5,0 @@ "main": "lib/uncss.js",

@@ -1,4 +0,34 @@

uncss
=====
# UnCSS #
Remove unused styles from CSS
Remove unused styles from CSS
## Installation: ##
npm install -g uncss
Usage
-----
### From the command line: ###
uncss [options] <file.html file.css ...>
Options:
-h, --help output usage information
-V, --version output the version number
-c, --compress Compress CSS
-o, --outfile [file] redirect the output to [file]
### Within node: ###
var uncss = require('uncss');
var css = ['my', 'array', 'of', 'css', 'files'],
html = ['some', 'html', 'files'],
options = {
compress: false,
outfile: 'css/style.min.css'
};
uncss(css, html, options);
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