https://github.com/flightaware/jsmin-tcl
A Tcl JavaScript minifier inspired by Douglas Crockford’s JSMin
https://github.com/flightaware/jsmin-tcl
Last synced: over 1 year ago
JSON representation
A Tcl JavaScript minifier inspired by Douglas Crockford’s JSMin
- Host: GitHub
- URL: https://github.com/flightaware/jsmin-tcl
- Owner: flightaware
- License: bsd-3-clause
- Created: 2015-03-18T13:33:33.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-09-14T22:27:32.000Z (almost 10 years ago)
- Last Synced: 2023-04-18T10:34:09.165Z (about 3 years ago)
- Language: Tcl
- Homepage:
- Size: 27.3 KB
- Stars: 3
- Watchers: 22
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
JSMin-Tcl
=========
JSMin-Tcl is a JavaScript minifier written in Tcl. Although inspired by Douglas Crockford's C-based JSMin, it has its own implementation and is **not** simply port. The behavior should be identical to Crockford's JSMin.
Behavior
--------
JSMin-Tcl removes all unnecessary whitespace from Javascript source code.
It will not rename your variables to shorter names, or "name mangle".
For example:
```javascript
var foo = "bar";
function example(arg0, arg1) {
console.log("example");
}
```
After minification becomes:
```javascript
var foo="bar";function example(arg0,arg1){console.log("example");}
```
Usage
-----
Minification is done using the "minify" proc in JSMin-Tcl. **Be sure to retain your original source file. Minification cannot be undone.**
```tcl
jsmin::minify inputChannel outputChannel
```
Example:
```tcl
package require jsmin
set fp [open "exampleFile.js"]
jsmin::minify $fp stdout
close $fp
```
If you want to directly pass a string of JavaScript and store the result in a variable you can do so like this:
```tcl
package require jsmin
set in [::tcl::chan::string $js]
set out [::tcl::chan::variable outstring]
jsmin::minify $in $out
```