GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
JS_COMPACTOR(1) User Contributed Perl Documentation JS_COMPACTOR(1)

js_compactor - Command line utility to reduce JavaScript code to as few characters as possible.

 js_compactor -src=source_file [OPTIONS]

js_compactor [--src=source_file] [--dest=destination_file] [--opt] [--comment_exception=text] [--remove_comments] [--replace_white_space] [--remove_blank_lines] [--combine_concats] [--join_all] [--replace_extra_whitespace] [--no_remove_comments] [--no_replace_white_space] [--no_remove_blank_lines] [--no_combine_concats] [--no_join_all] [--no_replace_extra_whitespace] [--force] [--help]

The "--src" option is required.

Default usage is as though you specified "--opt", for optimal settings. Setting any of the specific settings will override the default "--opt" behavior, and rules will be applied one by one. You may also specify "--opt" and then disable specific features with a "--no_option_name" style option.

The source javascript filename. (REQUIRED)
The destination file. Defaults to output to STDOUT.
Force overwriting of output file if it exists.
Same as --remove_comments --replace_white_space --remove_blank_lines --combine_concats --join_all --replace_extra_whitespace
Comments matching the provided text will NOT be removed. The primary purpose for this is to retain copyright notices. Eg.

    js_compactor --comment_exception=copyright -src=somefile
    

This option may be specified multiple times. Any comment matching any of the provided strings will then be retained.

It uses a case insenstive regexp for the match. This option has no effect if --no_remove_comments is specified.

Remove all comments from the source.
Per each line:
  • Removes all begining of line whitespace.
  • Removes all end of line whitespace.
  • Combined all series of whitespace into one space character (eg. s/\s+/ /g)

Comments and string literals (if still embeded) are untouched.

Blank lines in code are removed.
Removes any string literal concatenations. Eg.

    "bob and " +   "sam " + someVar;
    

Becomes:

    "bob and sam " + someVar
    
Put everything on one line (retained comments may still contain new lines).
This removes any excess whitespace. Eg.

    if (someVar = "foo") {
    

Becomes:

    if(someVar="foo"){
    

The normal use is probably just for one off squishings:

    js_compactor --src=input_file > new_file.js

If you're squishing something with a copyright, it is recommended that you retain that copyright:

    js_compactor --comment_exception=copyright --src=input_file > new_file.js

If you want the code to still be somewhat readable, it is often helpful to retain all the line breaks:

    js_compactor --opt --no_join_all --comment_exception=copyright --src=input_file > new_file.js

JavaScript::Squish

Please refer to http://developer.berlios.de/projects/jscompactor/ to report bugs.

Joshua I. Miller <jmiller@puriifeddata.net>

Copyright (c) 2005 by CallTech Communications, Inc.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.

2008-03-16 perl v5.40.2

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.