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:
and the server will minify it for you.
You can also bundle multiple files:
will join the files
/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:
This example will bundle and minify the two files
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 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" />