Should I Remove Unused CSS Code?

Hello, I am currently in the process of converting the CSS in my recent projects to SCSS (Sass), while simultaneously implementing Object-Oriented CSS. All of these projects share a lot of the same code as far as layouts and utilities go, and I was curious to know if it makes a difference if I keep unused code in some of these files, or should I just remove it.
For example:

// Padding
.py {
    &-0 { padding-block: 8px }
    &-1 { padding-block: 24px }
    &-2 { padding-block: 32px }
    &-3 { padding-block: 44px }
    &-4 { padding-block: 88px }

If the project I am currently working on doesn’t utilize the py-3 class, should I remove it and rename py-4? I’m not entirely sure how much of an effect that would have on rendering a page, but I’d imagine there is such thing as too many unused snippets of code. Thank you in advance!

you should remove it if you dont plan on ever using it.

leaving unused code will increase you file size and slow your website down. Plus it will confuse you or future programmers as to why the code is their in the first place.

If you think you might use it but not sure, you can always leave it in a comment block of code. then just make a note about it

Thank you for your response! I was initially under the impression it wouldn’t hurt to keep just in case classes, but commenting them out is a significantly better alternative. Thank you again!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.