So a long story short, cut to the chase, whatever you want to say… I’m going to start a new job in a few weeks, and they’ve asked me to get quite familiar with CSS. I won’t need it so much, but they said it’s good to know. I have a basic understanding of CSS, but I need to find a great compression/optimization tool to make my code cleaner. What modern online or offline tools are considered the best?
I’m not sure a CSS minifier (if that’s what you’re after) makes code any cleaner. Minified code is certainly more difficult to read. When I minify CSS I either use http://www.cleancss.com/css-minify/ (only because it comes up first in my search) or CSS Crush pre-processor.
There are browser add-ons to check for unused classes etc.in your CSS.
Look like some pretty solid options. Cheers. I did a bit more digging on the subject and came across this blog post https://www.1and1.com/digitalguide/websites/web-design/css-compression-for-consistent-loading-times/ and it suggested ‘CSS Minifier’ as one of the tools. It says it “shortens the code by removing line breaks and spaces as well as deleting the final semicolon in the list”, which is more or less what I’m after.
Is CSS Minifier essentially the same as the ones you guys suggested? And do the ‘pros’ use the same ones?
I would only use CSS compression if I modularize into multiple CSS files (which I don’t). If you have a single CSS file then I would just leave it. All it does is remove the new lines and empty spaces. You can’t compress any actual values. I believe it does ‘optimize’. I would just google ‘gulp css compress’ and use those.
‘Specificity’ I gather. The sooner you resort to ID’s, the more difficult it becomes to override them, and before you know it, you’re into using !important. I get the very distinct impression that class is favoured instead.
Id selectors have high specificity value and if used indiscriminately for “convenience” can cause problems if less specific rules try to over-ride them.
But I think at times they can be useful, and maybe even needed.
Which code editor do you use? Most of them can have linting tools installed as a plugin, and they are usually configurable to your own tastes, or can be turned off when not required.