Skip to content

Open source website and API to remove unused selectors from your CSS by analyzing your HTML

License

Notifications You must be signed in to change notification settings

biruk-kassaw/Clean-css

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clean-Css

License: MIT

What Is Clean-Css

When you are building a website, chances are that you are using a css framework like Bootstrap, Materializecss, etc... But you will only use a small set of the framework and a lot of unused css styles will be included.

This is where Clean-Css comes into play. Clean-Css analyzes your css. Then it matches the selectors used in your css files with your html files. It removes unused selectors from your css, resulting in smaller and optimized css file.

Usage

API

By sendeng a post request which contains the html and css as a string to this url: https://clean-css-ol7w.onrender.com/api/v1/remove-unused-css

Example using axios:

axios.post('https://clean-css-ol7w.onrender.com/api/v1/remove-unused-css', {
    html: '<p>hello</p>',
    css: 'p{color: red;}'
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });

Website

Go to this website: https://comfy-syrniki-a32afb.netlify.app/

- Copy&paste your HTML and CSS into boxes as shown below

Screenshot from 2022-12-28 11-16-53

- Click Clean up css button

Screenshot from 2022-12-28 11-19-25

- Use your clean css

Screenshot from 2022-12-28 11-20-14

Please note:

Clean-Css only runs the Javascript that is run on page load. It does not (and cannot) handle Javascript that runs on user interactions like button clicks.

-> The code for both the website and API can be found in this repository

About

Open source website and API to remove unused selectors from your CSS by analyzing your HTML

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published