Automatic Minification and Bundling

JavaScript and CSS files can be minified automatically for you.

Where you would have used the name of the source file(s) as the value of a ‘src’ attribute in the script tag, instead use an altered name:

JavaScript

Instead of:

<script src="mywork.js"></script>

use:

<script src="mywork.min.js"></script>

and the server will minify it for you.

You can also bundle multiple files:

<script src="/assets/js/one;two;three.min.js"></script>

will join the files /assets/js/one.js, /assets/js/two.js, and /assets/js/three.js into one file. Because the example ends with the min.js suffix, the bundle will be minified as well. Sources bundled this way need to be in the same directory.

If the sources are not in the same directory, a more verbose format will work:

<script src="/js/uno.min.js+/js2/dos.min.js"></script>

This example will bundle and minify the two files /js/uno.js and /js2/dos.js .

If you write the script tag wrong, you get a 404 rather than an error message, so verify, please. You can request the minified version directly by entering it into the browser’s address bar.

CSS

CSS files are minifiable and bundleable in the same style. The CSS forms of the above examples are:

<link rel="stylesheet" type="text/css" href="mywork.min.css" />
<link rel="stylesheet" type="text/css" href="css/one;two;three.min.css" />
<link rel="stylesheet" type="text/css" href="css/uno.min.css+/css2/dos.min.css" />

Relevant Blog Posts