Common tools are:
Here it is on Codeplex: http://minifyps.codeplex.com/
2020/11/17: Now on GitHub: https://github.com/ikarstein/minifyPS
You can use the module like this:
The module works like this:
1. Split script source code into typed chunks:
- Single Quoted String
- Double Quoted String
- Multiline Comment
- End-of-line Comment
2. Remove all unwanted chunks such as comments
3. Process all remaining chunks by using regular expressions
4. Combine all processed chucks to a result string
There are two files in the package at Codeplex:
- “minJS.psm1” => This is the module
- “minJSDemo.ps1” => This is a demo script that uses the module
This is a screenshot after running the demo script:
If you execute “minJSDemo.min.ps1” in the output folder you execute the minified version of “minJSDemo.ps1” and the minified version of the module itself (“minJSmin.psm1”).
The module is ALPHA at the moment. I’ve tested it in some projects and it seems to work as expected.
C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATELAYOUTS<lcid>CORE.debug.js
I’ve renamed the original file to “core.debug.js.bak”, minified it and saved the result as “code.debug.js”. So it’s used in the browser. (The minification of ~360KB takes 90 seconds.The minification module is slow…)
It’s not possible to use the minified version. It seems that the original “code.debug.js” has some bugs. For example in line 42: There is no trailing “;”
But because of removing the line break this results in:
I’d be happy to hear about your experiences with the module. Please post comment, write me an e-mail or join the Codeplex-project!
do you know Chirpy (http://chirpy.codeplex.com/).
Great concept. I tried using minifyPS as follows:
$str = [IO.File]::ReadAllText(“.\test.ps1”)
$min = (minify -inputData $str -inputDataType “ps1”)
Set-content -path .\test_min.ps1 -value $min
Unfortunately this resulted in parse exception errors…