Smarty Minify

Smarty Minify

by Admin 0 Comments 410

Smarty Minify (compression and packaging js, css and less)

This module allows you to compress and combine css, js, less files and codes with the ability to compress via gzip and further caching.

How to use:

In the template file where we display js and css (usually index.tpl), you need to place the codes:

{stylesheet minify=false} for css output (usually before </head>)
{javascript combine=false} for js output (usually before </body>)

these tags can take parameters (if they are not specified then they will be taken from the global settings in config/config.php):

  • combine=true - pack everything into one file / false - do not pack
  • minify=true - compress code / false - do not compress
  • id - identifier. Remove js or css from the queue with the specified id

These codes are used to display our scripts and styles.
Next, how to add js and css:
You can add them from any tpl you want. Add options:
Registering multiple files at once

{css id="libs" include=[

registration of 1 file:

{css id="theme" include="design/{$settings->theme}/css/theme.css"}{/css}

registration of 1 file and arbitrary code:

{css id="mycode" include="design/{$settings->theme}/css/mycode.css" render=true}
.my_class {
color: red

remove code from registration:

{unset_css id="mycode"}

these functions take parameters:

  • id* - serves for identification (required parameter)

  • include - a string or array of strings to add to the queue

  • priority - output priority. The default is 10 (if you do not specify the files, they will become one by one according to the function call) The higher the priority, the faster it will be on the output

  • less - if set to true then the syntax less will be applied to this resource and recoded into css. (default: false)

  • render - if this parameter is set to true, then the code will not be queued, but will be displayed right at the place of the function call. The minify and combine parameters are global to drill.

  • minify - if this parameter is set to true, then compression will be applied to this resource. If false - then files belonging to this id will not be compressed. (default: config.php value)

  • combine - if this parameter is set to true, then packing into one file will be applied to this resource. If false - then files belonging to this id will not be packed into one file. (default: config.php value)

Registering several js files at once:

{js id="libs" priority=99 include=[

Removing from the queue:

{unset_js id="mycode"}

No comments

No comments





To contact us