Compressing CSS with BBEdit

I've been noticing the compressed CSS that Drupal is creating for modules and wondered how easy it would be to compress the CSS my theme files use as well. Pretty simple process in BBEdit:

1) Go to Markup > Utilities > Optimize to strip out extra spaces and wrap to one line.

2) Use Find (Command-F), check the Grep checkbox, and in the Find field, enter the following regular expression to find all occurrences of comments and leave the replace field empty:

/\* .*? \*/

3) Click Replace All.

Done. If you want reformat, select Markup > CSS > Format. Be aware that all your comments will be gone though, so you might want to create a backup for reading.

Comments

01 Fabric
03/12/07 @ 16:17

Nice and easy way. I would never guess it. Thanks!

02 metheav
01/27/08 @ 19:56

Nice and easy way. I would never guess it. Thanks!

oyun hileleri

Advertisement

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <b> <strong> <dd> <dl> <dt> <i> <li> <ol> <u> <ul> <code> <blockquote>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options