Skip to content

flightaware/jsmin-tcl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

var foo = "bar";
function example(arg0, arg1) {
    console.log("example");
}

After minification becomes:

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.

jsmin::minify inputChannel outputChannel

Example:

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:

package require jsmin

set in [::tcl::chan::string $js]
set out [::tcl::chan::variable outstring]
jsmin::minify $in $out

About

A Tcl JavaScript minifier inspired by Douglas Crockford’s JSMin

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •