strip css made simple

How about a nice macro to help you quickly strip css and hide your comments over and over again?

Requirements:

- Windows (don't hate, just post the solution for your OS in the comments... :^p)
- AutoHotKey

What will the Macro do?

By typing "cssstrip" in your stylesheet, [[strip]] & [[/strip]] are added at the top and the bottom of your stylesheet.
This will remove all whitespace present in your stylesheet, reducing it's overall size.

By typing "csscomm" in your stylesheet, all /* & */ are replaced with [[* & *]].
This effectively prevents all your comments from appearing in the cached stylesheet, reducing it's overall size while allowing you to comment as much as you want.

How do i use the Macro?

- Install AutoHotKey
- create a new file and call it stripcss.ahk (or download the file)
- Paste the code below in the new file
- Run the file
- type "csscomm" or "cssstrip" in your stylesheet

The code

#NoEnv
#SingleInstance force

;################# AUTO-RELOAD #################

SetTimer,UPDATEDSCRIPT,1000

UPDATEDSCRIPT:
FileGetAttrib,attribs,%A_ScriptFullPath%
IfInString,attribs,A
{
FileSetAttrib,-A,%A_ScriptFullPath%
SplashTextOn,,,%A_ScriptName% reloaded,
Sleep,1000
Reload
}
Return

;################# css comments #################

:*:csscomm::
Search1 := "/\*"
Replace1 := "[[*"
Search2 := "\*/"
Replace2 := "*]]"
previous := % clipboard
Sleep 100
Send ^a
Sleep 100
Send ^c
newtext := RegExReplace(clipboard, Search1, Replace1, count)
newtext2 := RegExReplace(newtext, Search2, Replace2, count)
clipboard := % newtext2
Sleep 100
Send ^a
Sleep 100
Send ^v
clipboard := % previous
Sleep 100
Send ^{Home}
return

;################# strip css #################

:*:cssstrip::
Send ^{Home}
Sleep 100
Send [[strip]]
Sleep 100
Send ^{End}
Sleep 100
Send [[/strip]]
Sleep 100
Send ^{Home}
return

Greetings,
Manuel

ALL-INKL.COM - Webhosting Server Hosting Domain Provider

Comments