Automatic Resource Minification
Structr can be configured to automatically take care of resource minification for CSS and JavaScript files.
In the filesystem the user can create files of type MinifiedCssFile
or MinifiedJavaScriptFile
respectively.
These files can be configured to contain multiple CSS/JavaScript files and are automatically minified when
one of the files changes or the minification settings of the file changes.
JavaScript Minification
For JavaScript minification the Google Closure compiler is integrated into Structr. Currently, Structr only supports the configuration of the optimization level. The supported values are WHITESPACE_ONLY
, SIMPLE_OPTIMIZATIONS
and ADVANCED_OPTIMIZATIONS
.
From the closure compiler documentation:
The WHITESPACE_ONLY compilation level removes comments from your code and also removes line breaks, unnecessary spaces, extraneous punctuation (such as parentheses and semicolons), and other whitespace. The output JavaScript is functionally identical to the source JavaScript.
The SIMPLE_OPTIMIZATIONS compilation level [...] also performs optimizations within expressions and functions, including renaming local variables and function parameters to shorter names.
The ADVANCED_OPTIMIZATIONS compilation level [...] adds a variety of more aggressive global transformations to achieve the highest compression of all three levels. The ADVANCED_OPTIMIZATIONS level compresses JavaScript well beyond what is possible with other tools.
The properties dialogue enables the user to add/remove files to/from the minified file, select the optimization level and also shows the warnings and errors which occurred during minification. It also lets the user trigger a manual minification run.
The order of the files in the resulting minified file can be changed by simply dragging and dropping the rows in the resource list table.
CSS Minification
For CSS minification YUICompressor is used. Structr support the lineBreak configuration option which can be used to enforce a maximum line-length rule because some source control tools don’t like very long lines.
The dialogue behaves the same way it does for JavaScript files. Changes to settings trigger minification of the source files and the user can add/edit the file list.