Server-side Bundling and Minification

Some of us continue to do front-end dev without a front-end build system. And even if you are comfortable with your front-end build system, it can be burdensome to do all that for a small project.

Without a front-end build system, tasks like bundling and minifying CSS and JavaScript files can be a hassle, though. RdbHost now provides some server-side assistance with these task on projects hosted here.

If you have a CSS or JavaScript file in your account, you can request a minified version from a script tag, by just modifying the name in the src attribute. The servers missing-page handler (aka 404 handler) will create the minified version on demand.

For example, if you have a file bigdeal.js, referenced by a script tag.

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

If you want a minified version instead, just rewrite the script tag as:

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

and our server will minify the source and deliver to the browser.

You can also bundle multiple files into one, for download efficiency, with or without minifying. There are two forms for requesting a bundle.

1.List the files, with complete paths (absolute or relative) separated by '+' or '   '.

    <script src="/path/one.js+/path2/two.js"> </script>

2.If all the files are in the same directory, you can bundle them by joining the names with ';' (semicolon). The path is at the beginning, and the modifier ('min') and the target extension are at the end.

    <script src="path/one;two.js"></script>
    <script src="path/uno;dos.min.js"></script>

The server will bundle, and minify if appropriate, the files into one, and deliver it to the client.

CSS files can be minified and bundled in similar form:

    <script src="path/one.css+path1/two.css"></script>
    <script src="path/uno;dos.min.css"></script>

Caution

If you have files with those names, those static files will be delivered in lieu of the automatic minification and bundling described here.

comments powered by Disqus