Skip to main content

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

Installation

Using easy_install:

$ easy_install minimatic

Using pip:

$ pip install minimatic

Source code

Git repository is located at GitHub.com.

Usage

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.

Example

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)

Download files

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

Source Distributions

Minimatic-1.0.zip (12.5 kB view details)

Uploaded Source

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

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Egg

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

Uploaded Egg

File details

Details for the file Minimatic-1.0.zip.

File metadata

  • Download URL: Minimatic-1.0.zip
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Minimatic-1.0.zip
Algorithm Hash digest
SHA256 be3a7046026a0cc03792085c169bfb52bbcdf115b411d3d1e40254a7eaaa619e
MD5 d03092a06b1751665bf9d31231a76e85
BLAKE2b-256 2febc936a1ad4ef5be2989f8c31aa0a1fdc9a0d160018cd8ac93de99ba9f497e

See more details on using hashes here.

File details

Details for the file Minimatic-1.0.tar.gz.

File metadata

  • Download URL: Minimatic-1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Minimatic-1.0.tar.gz
Algorithm Hash digest
SHA256 e2d8a037f797ac3ba5aa81aae8ab6a84322c174ef3709a72a787d94c31a12d06
MD5 5e3d4e6d2683d16d8bf35dde5f33a2e1
BLAKE2b-256 4d419ba4bf266296e177a6d3b6af547a9b6b7a4780308afeb2249d9b5a1e541e

See more details on using hashes here.

File details

Details for the file Minimatic-1.0-py2.6.egg.

File metadata

  • Download URL: Minimatic-1.0-py2.6.egg
  • Upload date:
  • Size: 15.3 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Minimatic-1.0-py2.6.egg
Algorithm Hash digest
SHA256 c8f1f9a72c07e7df6120edd49864b454a7203ed24ec1725bc1c5b2ab9ddbf948
MD5 0fbf3c53a3a0bab11f282ab0488d68b0
BLAKE2b-256 f038608cd8240156f13c8c7e02c0b674efcb4ee947e334a3fed821db239de2cc

See more details on using hashes here.

File details

Details for the file Minimatic-1.0-py2.5.egg.

File metadata

  • Download URL: Minimatic-1.0-py2.5.egg
  • Upload date:
  • Size: 15.3 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Minimatic-1.0-py2.5.egg
Algorithm Hash digest
SHA256 54327a27dbff190e4b59c4553f801ca8ee1ce700dac4128a84fd27c9730c4ce5
MD5 5613d341aa836c609ace6d920cb7c0aa
BLAKE2b-256 5afc8045c19c1e191e854e88d47c8ab939d76332fccd7cf07fb004c447faa336

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page