I came up with this idea while trying to implement a code splitting technique on a website in order to reduce the amount of dead CSS rules per page.
Chrome does a great job showing you the unused CSS selectors in the stylesheet, but it's not so easy to do this dynamically for different pages.
For those of you who are wondering:
- The API calls are cached. They will not be a problem with performance.
- if an error happens, the service returns the original stylesheet - so the visitor will not see an unstyled website.
- if a certain class is included only after an user-action, it should be marked as such within the stylesheet and it will always be there.
- the difference with the CLI tools that do a similar task is that it's using Headless Chrome to fully execute the web page before searching for unused CSS selectors. The CLI tools usually perform a scan in your project files only.
- it's not a silver bullet for all possible web apps. But there are many cases where it would be big savings in CSS filesize.
If anyone has questions, feel free to contact me.
If you find it interesting, you can request early access on the website.
The product is simple but provides absolutely necessary functionality for a snappy page load. Even though existing CLI tools could do the same thing for you, nothing beats convenience and ease of use.