Spanish Total.js
English
Documentation For AI agents
Contents

Minification

U.minify_css(), U.minify_js() and U.minify_html().

.md GitHub
On this page

API

method

U.minify_css(css)

Minifies CSS and compiles nested rules and $variables.
ParameterTypeDescription
css String CSS source.

Returns String Minified CSS.

Removes comments and whitespace, shortens margin and padding (0 0 0 0 to 0, 10px 20px 10px 20px to 10px 20px) and colours such as #FFFFFF. A rule that contains only other rules is expanded (.a { .b { } } to .a .b{}). Variables are declared as $name: value; and used as $name. On an error the function logs CSS compiler error and returns an empty string.

Nested rules
U.minify_css('.menu {\n\t.item { color: red; }\n\t.active { font-weight: bold; }\n}');
// '.menu .item{color:red}.menu .active{font-weight:bold}'
Variables
U.minify_css('$brand: #0066FF;\n.button { background: $brand; }');
// '.button{background:#0066FF}'
method

U.minify_js(js)

Minifies JavaScript.
ParameterTypeDescription
js String JavaScript source.

Returns String Minified code.

Removes comments, line breaks and unneeded whitespace. Strings are kept as they are. It does not rename variables.

Minify
U.minify_js('if (a) {\n\tconsole.log(a); // log\n}'); // 'if(a){console.log(a);}'
method

U.minify_html(html)

Minifies HTML.
ParameterTypeDescription
html String HTML source.

Returns String Minified HTML.

Removes comments (not conditional comments such as <!--[if IE]>) and collapses runs of spaces between words to one space. Line breaks and indentation between tags are kept. The content of script, textarea, pre, code and readme is not changed. Inline script and style are minified with the JS and CSS minificators when $minifyjs and $minifycss are on.

Minify
var html = U.minify_html(source);
Made in Europe