{"id":21909315,"url":"https://github.com/rbtech/css-purge","last_synced_at":"2025-04-06T22:07:59.970Z","repository":{"id":7800899,"uuid":"9171206","full_name":"rbtech/css-purge","owner":"rbtech","description":"A CSS tool written in Node JS as a command line app or library for the purging, burning, reducing, shortening, compressing, cleaning, trimming and formatting of duplicate, extra, excess or bloated CSS.","archived":false,"fork":false,"pushed_at":"2022-12-07T22:11:14.000Z","size":1917,"stargazers_count":124,"open_issues_count":20,"forks_count":19,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-14T12:39:40.312Z","etag":null,"topics":["css","css-purge","cssmin","cssminifier","cssminify","duplicate-css-rules","nodejs","unusedcss"],"latest_commit_sha":null,"homepage":"http://rbtech.github.io/css-purge","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rbtech.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-02T13:48:17.000Z","updated_at":"2023-12-25T00:59:34.000Z","dependencies_parsed_at":"2023-01-11T20:10:36.175Z","dependency_job_id":null,"html_url":"https://github.com/rbtech/css-purge","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbtech%2Fcss-purge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbtech%2Fcss-purge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbtech%2Fcss-purge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbtech%2Fcss-purge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rbtech","download_url":"https://codeload.github.com/rbtech/css-purge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557767,"owners_count":20958047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","css-purge","cssmin","cssminifier","cssminify","duplicate-css-rules","nodejs","unusedcss"],"created_at":"2024-11-28T17:16:59.157Z","updated_at":"2025-04-06T22:07:59.955Z","avatar_url":"https://github.com/rbtech.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"http://rbtech.github.io/css-purge\" target=\"_blank\"\u003e\u003cimg align=\"right\" src=\"http://rbtech.github.io/css-purge/assets/images/visit_website.jpg\"\u003e\u003c/a\u003e\n\n\n[![npm](https://img.shields.io/npm/v/css-purge.svg)](https://www.npmjs.com/package/css-purge) [![npm](https://img.shields.io/npm/dm/css-purge.svg)](https://npmcharts.com/compare/css-purge?\u0026=true\u0026periodLength=30\u0026minimal=true) [![NpmLicense](https://img.shields.io/npm/l/css-purge.svg)](https://www.npmjs.com/package/css-purge)\n\n\n**V3 - We just released our most awesome version yet!**\n\n\n\n## A CSS tool written in Node JS as a command line app or library for the purging, burning, reducing, shortening, compressing, cleaning, trimming and formatting of duplicate, extra, excess or bloated CSS.\n\n\n[![CSS Purge](http://rbtech.github.io/css-purge/assets/images/CSS_Purge_Logo_Full.png)](http://rbtech.github.io/css-purge)\n\n\n\n\n\n\n## Overview\n\n#### Purging CSS\n\nThis is the typical usage scenario, where you may want to purge some CSS from a file(s) or folder(s) or CSS from your workflow (like from [gulp](https://gulpjs.com) or [grunt](https://gruntjs.com)).\n\n![Purging CSS](http://rbtech.github.io/css-purge/assets/images/overview1.png)\n\n#### Purging Unused CSS\n\nYou want to take it a step further by taking your CSS file(s) and reducing it further based on what is used in your HTML file(s).\n\n![Purging Unused CSS](http://rbtech.github.io/css-purge/assets/images/overview2.png)\n\n\n\n\n\n\nUsage\n----\n\n### CLI App Usage\nGlobal usage is nice for doing something quick everywhere.\n\n1) Install with npm:\n```\nnpm install css-purge -g\n```\n2) Run with options:\n```\ncss-purge [CLI options]\n```\n\nCLI Options:\n\n\nCommand | Description\n------------ | -------------\n-i \"filename/folder name location\" | CSS file(s) input\n-o \"filename\" | The new CSS filename to output as\n-c \"some CSS\" | input CSS from CLI\n-f \"config filename\" | run with a custom config filename\n-m \"filename/folder name/URL location\" | HTML file(s) input\n-d | run with the default config file (config_css.json must exist in folder)\n-v | displays the version number\n-h | CLI help\n\n##### Examples\n**CSS** - Purge some CSS and output to terminal\n```\ncss-purge -c \".panel { color:red; color: blue; }\"\n```\n**CSS file** - Purge CSS from main.css and output to main.min.css\n```\ncss-purge -i main.css -o main.min.css\n```\n**CSS file with Custom Config** - Purge CSS from main.css and output to main.min.css using myconfig.json for configuration\n```\ncss-purge -i main.css -o main.min.css -f myconfig.json\n```\n**CSS file with HTML file** - Purge CSS from main.css using index.html to compare and output to main.min.css\n```\ncss-purge -i main.css -o main.min.css -m index.html\n```\n**Multiple CSS and HTML files** - Purge CSS from main.css and framework.css (in that specific order) using index.html and index.html from www.mywebsite.com to compare and output to main.min.css\n```\ncss-purge -i \"main.css, framework.css\" -o main.min.css -m \"index.html, http://www.mywebsite.com/index.html\"\n```\n\n\n\n\n\n\n\n### Project Usage\nLocal usage is nice for “setting up shop” for a project.\n\n1) Clone with [git](https://git-scm.com)/[GitHub Desktop](https://desktop.github.com/):\n```\ngit clone https://github.com/rbtech/css-purge.git\n```\nor download from: [https://github.com/rbtech/css-purge](https://github.com/rbtech/css-purge)\n\n2) Install dependencies:\n```\nnpm install\n```\n\n3) Run with options\n```\nnode css-purge [CLI options]\n```\n\nCLI Options:\n\n\nCommand | Description\n------------ | -------------\n-i \"filename/folder name location\" | CSS file(s) input\n-o \"filename\" | The new CSS filename to output as\n-c \"some CSS\" | input CSS from CLI\n-f \"config filename\" | run with a custom config filename\n-m \"filename/folder name/URL location\" | HTML file(s) input\n-d | run with the default config file (config_css.json must exist in folder)\n-v | displays the version number\n-h | CLI help\n\n\n\n\n\n### Node JS Library Usage\nLibraries help share the awesomeness to more people :)\n\nYou can test out the library in your browser [here](https://npm.runkit.com/css-purge).\n\nInstall:\n```\nnpm install css-purge --save\n```\n\nSome example usage:\n\n```javascript\n var cssPurge = require('css-purge');\n  \n  //purging a CSS string with options\n  var css = \"p { color: blue; color: blue; } \";\n\n  cssPurge.purgeCSS(css, {\n    trim : true,\n    shorten : true\n  }, function(error, result){\n    if (error)\n      console.log(error)\n    else\n      console.log('Output CSS: ',  result);\n  });\n\n\n  //uses default settings that are set in the config file\n  //make sure that css is set\n  cssPurge.purgeCSSFiles();\n  \n  //purging a CSS file\n  cssPurge.purgeCSSFiles({ \n    css:'demo/test1.css' \n  });\n  \n  //purging a CSS file with HTML\n  cssPurge.purgeCSSFiles({\n    css: 'demo/test1.css', \n    html: 'demo/html/test1.html'\n  });\n  \n  //purging a CSS file with HTML and options\n  cssPurge.purgeCSSFiles({\n    css_output: 'test1.min.css',\n    css: 'demo/test1.css', \n    html: 'demo/html/test1.html',\n    trim : true,\n    shorten : true,\n    verbose : true\n  });\n  \n  //purging a CSS file with HTML, options and config\n  cssPurge.purgeCSSFiles({\n      css_output: 'test1.min.css',\n      css: 'demo/test1.css', \n      html: 'demo/html/test1.html',\n      trim : true,\n      shorten : true,\n      verbose : true\n    },\n    'myconfig.json'\n  );\n\n```\n\n\n\nCSS-Purge Report Viewer\n----\n[![Report Preview](http://rbtech.github.io/css-purge/assets/images/css_purge_report.jpg)](http://rbtech.github.io/css-purge)\n\nOpen a separate terminal window, then:\n1) Clone with [git](https://git-scm.com)/[GitHub Desktop](https://desktop.github.com/):\n```\ngit clone https://github.com/rbtech/css-purge-report-viewer.git\n```\nor download from: [https://github.com/rbtech/css-purge-report-viewer](https://github.com/rbtech/css-purge-report-viewer)\n\n2) Install reload:\n```\nnpm install reload -g\n```\n\n3) Run reload to view the report:\n```\nreload -b -e html, css, js, json\n```\n\nReport notes:\n- make sure you are in the report viewers directory before running reload\n- make sure CSS-Purge is set to generate into the report viewers directory\n\n\nConfig Options\n----\nFor an overview of some of the options/features, \nhave a look [Under the hood](http://rbtech.github.io/css-purge/#features).\n\nFull description of each option can be found on the [website](http://rbtech.github.io/css-purge) (Getting Started \u003e Config).\n\nExample config.json:\n```json\n{\n  \"options\": {\n    \"css_output\": \"purged.min.css\",\n    \"css\": \"demo/html/static-jekyll/_siteassets/main.css\",\n    \n    \"html\": \"demo/html/static-jekyll/_site\",\n    \n    \"new_reduce_common_into_parent\": true,\n    \n    \"trim\": true,\n    \"trim_keep_non_standard_inline_comments\": false,\n    \"trim_removed_rules_previous_comment\": true,\n    \"trim_comments\": false,\n    \"trim_whitespace\": false,\n    \"trim_breaklines\": false,\n    \"trim_last_semicolon\": false,\n    \n    \"shorten\": true,\n    \"shorten_zero\": false,\n    \"shorten_hexcolor\": false,\n    \"shorten_hexcolor_extended_names\": false,\n    \"shorten_hexcolor_UPPERCASE\": false,\n    \"shorten_font\": false,\n    \"shorten_background\": true,\n    \"shorten_background_min\": 2,\n    \"shorten_margin\": false,\n    \"shorten_padding\": false,\n    \"shorten_list_style\": false,\n    \"shorten_outline\": false,\n    \"shorten_border\": false,\n    \"shorten_border_top\": false,\n    \"shorten_border_right\": false,\n    \"shorten_border_bottom\": false,\n    \"shorten_border_left\": false,\n    \"shorten_border_radius\": false,\n    \n    \"format\": true,\n    \"format_4095_rules_legacy_limit\": false,\n    \"format_font_family\": true,\n    \n    \"special_convert_rem\": false,\n    \"special_convert_rem_browser_default_px\": \"16\",\n    \"special_convert_rem_desired_html_px\": \"10\",\n    \"special_convert_rem_font_size\": true,\n    \n    \"special_reduce_with_html\" : false,\n    \"special_reduce_with_html_ignore_selectors\" : [\n      \"@-ms-\",\n      \":-ms-\",\n      \"::\",\n      \":valid\",\n      \":invalid\",\n      \"+.\",\n      \":-\"\n    ],\n    \n    \"generate_report\": true,\n    \"verbose\": true,\n    \n    \"bypass_media_rules\": true,\n    \"bypass_document_rules\": false,\n    \"bypass_supports_rules\": false,\n    \"bypass_page_rules\": false,\n    \"bypass_charset\": false,\n    \n    \"zero_units\": \"em, ex, %, px, cm, mm, in, pt, pc, ch, rem, vh, vw, vmin, vmax\",\n    \"zero_ignore_declaration\": [],\n    \n    \"report_file_location\": \"report/purged_css_report_data.json\",\n    \n    \"reduce_declarations_file_location\": \"config_reduce_declarations.json\"\n  }\n}\n```\n\n\n\n\nPlugins!\n----\n- [gulp-css-purge](https://github.com/rbtech/gulp-css-purge)\n- [grunt-css-purge](https://github.com/dominikwilkowski/grunt-css-purge)\n- [Webpack loader : purge-css-loader](https://github.com/dzianisreznik/purge-css-loader)\n\n\nWe will list them as they come.\n\n\n\n\n\n\nHelp\n----\n##### Source Code Issues\n- [Visit the issues section on github](https://github.com/rbtech/css-purge/issues)\n\n##### Community and Q\u0026A \n\nGot a question on how to do something and when answered will help everyone? \nThen place it on StackOverflow with the tag \u0026ldquo;css-purge\u0026rdquo; \n- [View questions tagged with \u0026ldquo;css-purge\u0026rdquo;](https://stackoverflow.com/questions/tagged/css-purge)\n- Join us on gitter - [Visit the community](https://gitter.im/css-purge)\n\n\n\n\n\n\n\n\nLicense\n-----\n\n(The MIT License)\n\nCopyright (c) 2017 [Red Blueprint Technologies](http://redblueprint.com)\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frbtech%2Fcss-purge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frbtech%2Fcss-purge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frbtech%2Fcss-purge/lists"}