Minifying js and css file has been a standard practice to reduce the webpage size.
Various tools are created to tackle the problem, especially on Mac OS X that includes batch processing capabilities.
However, it is a pain to do so in Windows without installing 3rd party extension into IDE.
This motivate me to write a simple script that can batch processing the js and easy to use.
The script will scan current folder and its sub folder.
copy it to your /js folder and run it.
Feel free to copy and modify.
It will save the minified file with .min.js or .min.css
This batch script required AjaxMin to run, install AjaxMin into its default folder
C:\Program Files (x86)\Microsoft\Microsoft Ajax Minifier
@ECHO offsave the script as .bat file
set PATH="C:\Program Files (x86)\Microsoft\Microsoft Ajax Minifier\";%PATH%
setlocal enabledelayedexpansion
for /f %%f in ('dir /b /s^|findstr /r ".*\.js$ .*\.css$"') do (
set "N=%%f"
if "!N:.min%%~xf=!"=="!N!" (
@ajaxmin -clobber %%f -o %%~npf.min%%~xf
)
)
pause
copy it to your /js folder and run it.
Feel free to copy and modify.
No comments:
Post a Comment