Is there a recommended tool for minifying CSS files in order to satisfy Google's Page Speed Insights? Should I just start with the minified file PSI provides?
NickMNS
3:42 pm on Jan 19, 2018 (gmt 0)
Just Google online css minifier, and use whatever tool is presented.
There is nothing magic in minifying all it does is remove, tabs, useless white spaces, carriage returns, line feeds and comments.
robzilla
4:13 pm on Jan 19, 2018 (gmt 0)
There can be some byte-saving "magic" like value optimizations, e.g. color: #000 instead of color: #000000, border: 2px instead of border: 2px 2px 2px 2px, outline: 0 instead of outline: none, etc. Depends on how you write your CSS. Some minifiers can even group certain rules together if they share declarations, but that can be dangerous.
Don't optimize to satisfy a tool. That's not the point. Do it for your users. What's best according to the tool may not be best for your users.
JonathanEdmonton
8:34 pm on Jan 19, 2018 (gmt 0)
Don't optimize to satisfy a tool. That's not the point. Do it for your users. What's best according to the tool may not be best for your users.
NIce answer. By the way I'll take a peek on YUI compressor. I've never heard about it before.
keyplyr
2:21 am on Jan 20, 2018 (gmt 0)
Just a reminder... always backup a file *before* altering it in case you need to use it again.
Jennnnn
4:03 am on Jan 20, 2018 (gmt 0)
I will. Thanks!
lucy24
7:35 pm on Jan 20, 2018 (gmt 0)
Oh, and ... don't be surprised if Page Speed continues to recommend minifying css/js even after you have minified them. You could compress your jpgs down to 10% (is it a blazing log? is it an orangutan? what's that greenish blob in the corner?) and they'd still recommend compressing images.
robzilla
11:05 pm on Jan 20, 2018 (gmt 0)
It's common practice to save an optimized copy of the original file (e.g. stylesheet.css) as a separate file (e.g. stylesheet.min.css). That way you always have a backup. (If you mess up, you could always rectify by "beautifying" the minified file -- lots of fying going on there). My preferred process after finishing work on a CSS or javascript file is to run a script that minifies the contents and stores both a separate plain-text copy (stylesheet.min.css) as well as a GZIPped version (stylesheet.min.css.gz) to save the server from having to do GZIP compression on-the-fly every time the file is requested even though the contents don't change very often. My precious CPU cycles.
Jennnnn
11:13 pm on Jan 20, 2018 (gmt 0)
I successfully uploaded 2 different minified CSS files and have saved 2 copies of each "working" (unminified) CSS file. Thanks so much for your help!