1. Pablo Caro Revuelta
  2. jspack


jspack /

Filename Size Date modified Message
78 B
85 B
180 B
702 B
412 B
39 B
4.1 KB
3.5 KB
284 B
1.3 KB


jspack is a simple and small tool to aggegate javascript files with optional miminization.

The tool allows also:

  • Create initial configuration files from html files
  • Reemplace in html script tags by minimized ones.

The project is open source.

A similar tool is jstools which do recursive search for the javascript files and also support dependencies.


Python 2.6

For javascript minimization you can use:


You can install jspack like a simple python egg:

  • Using easy_install: easy_install jstools
  • Using pip: pip install jstools
  • If you use buildout, add it to the eggs list in your buildout.cfg, or as a dependency of one of your own packages in setup.py.

The code is available in the jspack repo


If you have a config file (test.cfg) like:

minimizer = jsmin

# yui compressor
minimizer = inout: java -jar compressor.jar --type js
# Can be used to replace the js tags
html = test.html
files = file/relative/to/root.js

minimizer = slimit
files = file/relative/to/root.js

root = css
minimizer = none
files = one.css

And generates concatenated.js, compressed.js and css/all.css

If root option is not specified, the relative files are considered relative to the config parent directory (test.cfg).

You can use the help:

$ bin/jspack  --help
jspack [options] file_or_directory

Typical Usage:

1. First create cfg files:
   $ jspack -w htmlfile_or_directory
2. Now we can edit the jspack.cfg files and customize
3. Then generate minimized:
   $ jspack cfgfile_or_directory
4. Last, replace script tags:
   $ jspack -rn cfgfile_or_directory

Note: 3 and 4 can be summarized which: $ jspack -r cfgfile_or_directory

  -h, --help            show this help message and exit
  -w, --write-config    For each FILE.html file write a FILE.jspack.cfg file
                        which later can be used to produce FILE-minimized.js
  -o, --ovewrite-config
                        Overwrite a jspack.cfg file if exists. Use which -w
  -i INCLUDE, --include-only=INCLUDE
                        When parsing html (to generate a .jspack.cfg file) ,
                        include only javascript files which match this regular
                        expression. Default (?!http), Use  for no restriction
  -s, --allow-strict-mode
                        When concatenate js files, dont't drop 'use strict'
                        lines. Default is remove strip mode
  -n, --no-pack         no packing when using the jspack.cfg. Only usefull
                        with -r option for only replace
  -r, --replace-script-tags
                        Replace the script tags in html files
  -q, --quiet           Supress non error output
  -v, --verbose         Vebose output (debug mode)


  • CSS links replacement in html files
  • Better documentation
  • Tests