UNPKG

css-unused-cleaner

Version:

Detect and remove unused CSS selectors with intuitive browser UI. Analyze HTML/CSS files and safely clean up unused styles with real-time preview.

120 lines (89 loc) โ€ข 3.55 kB
# CSS Unused Cleaner ๐Ÿงน **Detect and remove unused CSS selectors with intuitive browser UI** A powerful CLI tool that analyzes your HTML/CSS files, identifies unused selectors, and provides a browser-based interface for safe cleanup with real-time preview. ## โœจ Features - ๐Ÿ” **Smart Analysis**: Automatically detects HTML and CSS files in your project - ๐ŸŒ **Browser Interface**: Intuitive web UI for managing selectors - ๐Ÿ“ฑ **Real-time Preview**: See changes instantly with live HTML preview - ๐ŸŽฏ **Categorized Selectors**: Organized by Layout, Typography, Components, etc. - ๐Ÿ’พ **Safe Cleanup**: Create new files or backup originals before overwriting - โšก **Fast & Lightweight**: Built with performance in mind ## ๐Ÿš€ Quick Start ```bash # Run on current directory npx css-unused-cleaner # Run on specific directory npx css-unused-cleaner ./my-website # Specify custom port npx css-unused-cleaner --port 3000 ``` The tool will: 1. Analyze your HTML/CSS files 2. Open browser interface at `http://localhost:3456` 3. Show categorized selectors with usage status 4. Allow safe removal with preview ## ๐Ÿ“Š Browser Interface ### Categorized Selector View - ๐Ÿ—๏ธ **Layout & Structure**: containers, grids, flexbox - ๐Ÿ“ **Typography**: headings, text, fonts - ๐ŸŽฏ **Header**: navigation, branding, hero sections - ๐Ÿ“ฆ **Cards & Components**: widgets, modals, alerts - ๐Ÿ”˜ **Buttons**: CTAs, form buttons - ๐Ÿ“‹ **Forms**: inputs, validation, contact forms - And more... ### Safety Features - **Dual Save Options**: Create new files or overwrite with backup - **Usage Indicators**: Clear marking of unused selectors - **Real-time Stats**: Track cleanup progress - **Instant Preview**: See changes before saving ## ๐Ÿ“ Supported Project Types - โœ… Static HTML/CSS websites - โœ… Bootstrap projects - โœ… WordPress themes - โœ… React build outputs - โœ… Documentation sites - โœ… E-commerce sites - โœ… Nested project structures ## ๐Ÿ› ๏ธ CLI Options ```bash npx css-unused-cleaner [directory] [options] Options: -p, --port <port> Server port (default: 3456) --no-open Don't open browser automatically -h, --help Display help information -V, --version Display version number ``` ## ๐Ÿ“ธ Example Output ``` ๐Ÿงน CSS Cleaner Analyzing project: /path/to/your/website ๐Ÿ“Š Analyzing HTML and CSS files... โœ… Analysis complete! Total selectors: 247 Unused candidates: 89 HTML files: 5 CSS files: 3 ๐Ÿš€ Starting server on port 3456... โœ… Server started at http://localhost:3456 ๐ŸŒ Opening browser... ``` ## ๐Ÿƒโ€โ™‚๏ธ Workflow 1. **Analyze**: Scan HTML/CSS files and detect unused selectors 2. **Review**: Use browser UI to examine categorized selectors 3. **Preview**: See real-time changes in HTML preview 4. **Clean**: Save optimized CSS with unused selectors removed 5. **Deploy**: Use cleaned CSS files in production ## ๐Ÿค Why CSS Unused Cleaner? - **Human-friendly**: Visual interface beats command-line only tools - **Safe & Reliable**: Always backup, never break your site - **Smart Categorization**: Find selectors by logical grouping - **Production Ready**: Handle real-world project complexity ## ๐Ÿ“‹ Requirements - Node.js 16.0.0 or higher - Modern web browser for interface ## ๐Ÿ› Issues & Support Found a bug or have a suggestion? Please [open an issue](https://github.com/css-cleaner/css-cleaner/issues). ## ๐Ÿ“„ License MIT License - see [LICENSE](LICENSE) file for details. --- Made with โค๏ธ for cleaner, faster websites