In: , , ,
On: 2007 / 05 / 22
Shorter URL for this post: http://ozh.in/en

I've been using CSSTidy lately, and I like it a lot. This is a pretty cool software that optimizes CSS files so that they are smaller and cleaner. It comes with a bunch of options and is available in Linux, OSX and Windows flavors.

CSSTidy context menu I'm running Windows on my test computer, and I made a convenient right click context menu on CSS files so I can clean them in one click. Here's how I did it:

  1. Download CSSTidy of course, and put the executable file csstidy.exe in, say, d:\utils\csstidy\
  2. Create the following file csstidy.bat in the same directory :
    1. @echo off
    2. if "%1"=="" goto notok
    3.  
    4. copy %1 %~d1%~p1%~n1.orig%~x1
    5. d:\utils\csstidy\csstidy.exe %1 --preserve_css=false --remove_bslash=false --compress_colors=true --lowercase_s=true --timestamp=false --remove_last_;=true --compress_font-weight=true --allow_html_in_templates=false --silent=false --case_properties=1 --sort_properties=false --merge_selectors=0 --sort_selectors=false --template=default %1
    6. goto end
    7.  
    8. :notok
    9. echo Missing parameter: no filename !
    10. pause
    11.  
    12. :end

    This bat file is a wrapper that will first backup your myfile.css to myfile.orig.css, then call csstidy.exe with pretty standard options: remove comments, remove indents, keep the file readable, etc…

  3. Now let's add the neato context menu to .css files :
    • Open the Control Panel and choose Folder Options. Select the 'File Types' tab, and look for the 'CSS' item. Click on 'Advanced', then click on 'New…'
    • In 'Action', type 'CSSTidy', and in 'Application used to perform action', enter the following command:
      1. d:\utils\csstidy\csstidy.bat "%1"

You're done ! It even works the same if you select multiple CSS files, right-click and pick CSSTidy in the context menu. Of course, remember to change the paths to reflect your own installation.

Shorter URL

Want to share or tweet this post? Please use this short URL: http://ozh.in/en

Metastuff

This entry "One-Click CSS Tidy Cleaning" was posted on 22/05/2007 at 10:32 pm and is tagged with , , ,
Watch this discussion : Comments RSS 2.0.

No Comment yet

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar and sign for a free account
Spam: Various spam plugins may be activated. I'll put pins in a Voodoo doll if you spam me.

Read more ?