readme.txt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. This is a node.js module for minimizing javascript (jsmin for short).
  2. It was originally written by Doug Crockford (www.crockford.com), was ported
  3. to javascript by Franck Marcia (www.fmarcia.info), which in turn was ported
  4. to node.js by Peteris Krumins (www.catonmat.net).
  5. ------------------------------------------------------------------------------
  6. The module exports 'jsmin' function:
  7. var jsmin = require('jsmin').jsmin;
  8. The 'jsmin' function takes three arguments:
  9. * input js code
  10. * integer aggressiveness level (defaults to 2)
  11. * optional comment to prepend to output (defaults to nothing)
  12. The aggressiveness level can be 1, 2 or 3:
  13. * 1 - keep original newlines in output
  14. * 2 - original Crockford's algorithm - remove some newlines
  15. * 3 - remove all newlines
  16. Start the comments that you don't want to remove (as process of minification)
  17. with /*! ... */
  18. Example
  19. -------
  20. var jsmin = require('./jsmin').jsmin;
  21. var sys = require('sys');
  22. sys.puts(jsmin('function hello( a , b , c ) { sys.log(a + b + c) }'))
  23. Output:
  24. 'function hello(a,b,c){sys.log(a+b+c)}'
  25. Command-line Usage
  26. ------------------
  27. Installing globally (using npm's -g flag) will also install a command-line
  28. tool for using jsmin:
  29. jsmin [OPTIONS...] [FILENAME]
  30. The input filename should be the last argument. If you don't specify it,
  31. input will be read from STDIN instead.
  32. Supported options:
  33. -o FILENAME
  34. --output FILENAME
  35. Specifies an output file for minified output. If not given, output
  36. will be written to STDOUT.
  37. -l LEVEL
  38. --level LEVEL
  39. Sets the aggressiveness level to be used.
  40. -c COMMENT
  41. --comment COMMENT
  42. Sets a comment to be prepended to the output.
  43. --overwrite
  44. If provided and an input filename was provided (rather than using
  45. STDIN), output will be written to the same file input was read from.
  46. ------------------------------------------------------------------------------
  47. Have fun jsminning!
  48. Sincerely,
  49. Peteris Krumins
  50. http://www.catonmat.net