Optimizing CSS within PHP/Web Storm

Optimizing CSS.


I’m looking for a plugin or an advice how to optimize CSS within PHP/Web Storm (removing white spaces, grouping, etc…)

Thank you guys,

Alex

0
4 comments

ctrl+shift+j  will take the selected text and turn it into a single line

so
.someclass{
     width:50px;
     height:100px;
     text-alignment:center;
}

will become:
.someclass{     width:50px;     height:100px;     text-alignment:center;}

you could select the entire file and keep hitting ctrl+shift+j to progressively get the entire file down to a single line.

I dont know of a shortcut that will do the entire file in one go.

The opposite is ctrl+shift+l  for "reformat code"

0

Thank you,

Thats a very good start :)

Alex

0

You can also use External Tools (Settings | External Tools -- then such entries can be available in Main Menu -> Tools, different context menus).

Using External Tools functionality you can utilize such tool like YUI Compressor (more detailed about CSS part here) or similar. It is more build/pre-deploy time tool but can be configured (to a some degree) to do some very simple optimisations (instead of more advanced). Use it when deploying your project to production server (so that you have detailed/convenient to use CSS file on your local PC for development purposes and optimized version on production server to reduce time and traffic (as it will be optimized -- no useless whitespace; all file in single line; optimized properties etc))

0

Thank you Andriy

That's exactly what I need. ;)

Alex

0

Please sign in to leave a comment.