Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Unused CSS

Featured Replies

Is there a tool to find out if any custom class or id in my css file is currently unused?

I'm talking about the id/classes I've created, eg:

.main-hero

#technology

#technology ul

 

etc.

I'm in the process of reorganising it but first would like to get rid of anything that is not used.

 

Thank you

 

You can actually automate this too using https://purgecss.com, which is what I do to remove extra utility classes that I don't use in my CSS file. It's quite advanced to setup though so I'd only consider it if it's something you really need.

  • Author

That's a neat idea. Can it just highlight the unused classes (as opposed to removing them) so the user can review it before deleting?

 

 

1 hour ago, portia79 said:

That's a neat idea. Can it just highlight the unused classes (as opposed to removing them) so the user can review it before deleting?

 

 

I don't think so, it's designed to be used before deploying code to a live site, so there's no benefit of doing manual checks and keeping code. It would actually take forever to review some codebases if you had to do this every time.

I wouldn't bother using something like PurgeCSS unless you're really familiar with frontend tooling, otherwise you'll give yourself a lot of headaches. It's nice to know tools like this exist, but they have quite advanced use cases. For most sites you likely wouldn't need to remove unused CSS, it's one of those things that's actually not that common.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.