Skip to main content

CSS and Javascript Minification/Combination Upgrade to WebHelpers

Project description

An extension to WebHelpers that enables a real time JS/CSS combination and minification in production mode.


Using easy_install:

$ easy_install minimatic

Using pip:

$ pip install minimatic

Source code

Git repository is located at


It extends the WebHelpers functions javascript_link and stylesheet_link to take a modified set of parameters:

  • sources (list): JS/CSS items to process. Each item is one of the following:
    • (dict) with keys:
      • file: a path to the source file relative to the static file root
      • minify: minification method. Possible values (default False):
        • False (bool): use the source unmodified
        • strip (str): only strip extra whitespace and comments (applicable to CSS only)
        • minify (str): strip whitespace and apply other possible JS/CSS minifications. Note that this involves source parsing and will err on syntax errors (CSS hacks will be removed!). In effect the resulting file may be logically different
      • dest: if the source list is not combined then each item must provide a destination filename relative to the static file root
    • (str): it will be treated as (see above):

      {'file': (str), 'minify': False}
  • combined (str): the combined filename relative to the static file root. Implies that the files need to be combined. If combined is None then every Item must have a dest key provided.

  • beaker_kwargs (dict): override default arguments that will be passed to beaker_cache. beaker_kwargs.update() is issued on default arguments.

  • timestamp append time.time timestamp to links to force browsers reload the JS/CSS assets, eg. test.js?t=123012343

The files will be combined in production mode; in development mode (debug=True) they will be served unmodified separately.


Mix and match the sources into one big JS file:

>>> javascript_link(
...     # These files are already minified; combine them only
...     '/js/jquery.js',
...     '/js/jquery-ui-custom.js',
...     # These are custom files which need to be minified first
...     dict(file='/js/base.js', minify='minify'),
...     dict(file='/js/page-script.js', minify='minify'),
...     combined='/combined/js/scripts.js',
...     timestamp=True)

Serve CSS files separately (uncombined):

>>> stylesheet_link(
...     # This stylesheet is valid CSS and safe to parse and minify
...     dict(file='/css/base.css', minify='minify',
...         dest='/combined/css/base.css'),
...     # This stylesheet is full of CSS hacks and only the extra whitespace
...     # and comments should be stripped
...     dict(file='/css/styles.ie6.css', minify='strip',
...         dest='/combined/css/styles.ie6.css'),
...     timestamp=True)

Project details

Release history Release notifications | RSS feed

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions (12.5 kB view hashes)

Uploaded source

Minimatic-1.0.tar.gz (8.1 kB view hashes)

Uploaded source

Built Distributions

Minimatic-1.0-py2.6.egg (15.3 kB view hashes)

Uploaded 2 6

Minimatic-1.0-py2.5.egg (15.3 kB view hashes)

Uploaded 2 5

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page