2023-06-09
2460
#css
Hamsa Harcourt
84343
Jun 9, 2023 â‹… 8 min read

Guide to removing unused CSS code with PurgeCSS

Hamsa Harcourt I'm Hamsa, a software engineer with a strong passion for building human-centric products. I love teaching concepts about JavaScript and the web at large.

Recent posts:

Using React Shepherd To Build A Site Tour

Using React Shepherd to build a site tour

React Shepherd stands out as a site tour library due to its elegant UI and out-of-the-box, easy-to-use React Context implementation.

Onuorah Bonaventure
May 1, 2024 â‹… 14 min read
A Guide To Cookies In Next Js

A guide to cookies in Next.js

Cookies are crucial to web development. This article will explore how to handle cookies in your Next.js applications.

Georgey V B
Apr 30, 2024 â‹… 10 min read
Handling Dates In JavaScript With Tempo

Handling dates in JavaScript with Tempo

Use the Tempo library to format dates and times in JavaScript while accounting for time zones, daylight saying time, and date internationalization.

Amazing Enyichi Agu
Apr 30, 2024 â‹… 8 min read
A Guide To Deno.cron

A guide to Deno.cron

This guide explores how to use the cron package in Deno, `Deno.cron`, to handle scheduling tasks with specific commands.

Rosario De Chiara
Apr 29, 2024 â‹… 5 min read
View all posts

6 Replies to "Guide to removing unused CSS code with PurgeCSS"

    1. Keep in mind that PurgeCSS doesn’t touch your source CSS files, just the ones that are output by the build process. So if you add new code that needs CSS rules that were previously purged, then the next time you build your app PurgeCSS will see that your code is using some new rules and will not purge them in that build.

  1. In frameworks such as Angular, you can use scss which is complied down to css. Is there any way to achieve this on scss?

    1. It doesn’t make sense to run it on SCSS because other SCSS files might be referencing your code dynamically elsewhere. You can transpile it to CSS, then run the process on CSS as part of your CI pipeline or have a local git hook to do so. It has the same effect.

Leave a Reply