Loads compressed JavaScript files to the page, whenever possible directly from the cache memory.

Kuvaus

Using the tag improves theme performance, especially if e.g. multiple JavaScript libraries are used.

By default, {MinifyJS} also outputs the scripts printed by the {SupportScripts} tag.

See also the {MinifyCSS} tag, which allows you to add compressed CSS files to the page.

Syntaksi

{MinifyJS( files: string, mode: string, support_scripts: boolean )}

Näkyvyys

Toimii näkyvyydessä: globaali

It is possible to use global visibility tags in any page template and within any tag.

Loading minified theme scripts

{MinifyJS( files:'js/jquery.171.min.js|js/mcf.main.js|js/mcf.checkout.js', mode: 'development' )} 

While the theme is still in the development phase, the {MinifyJS} tag's mode attribute is set to 'development', so scripts are not loaded from the cache but directly from the server with each page load. In this way, all changes will become visible in the theme immediately.

Once the theme development is complete and the site is launched, it is advisable to change the {MinifyJS} tag's mode attribute to 'production'; this improves the theme's performance as scripts are loaded in a compressed form and, if possible, from the cache.

{MinifyJS( files:'js/jquery.171.min.js|js/mcf.main.js|js/mcf.checkout.js', mode: 'production' )} 

Attribuutit

files:

Defines which files should be loaded by the tag.

The attribute's values are pipe separated file locations in relation to the theme's root directory.

E.g. files:'js/jquery.171.min.js|js/mcf.main.js|js/mcf.checkout.js',

mode:

Defines a state for the tag based on which files are loaded either as packed or unpacked.

Allowed values:

  • 'production': In production, files are loaded compressed from the cache.
  • 'development': In development, files are loaded anew at every page load, so that potential changes become visible immediately.
support_scripts:

Sets the tag to also print all the JavaScript files printed by the {SupportScripts} tag. In this case, the {SupportScripts} tag does not need to be added to the theme separately.

Allowed values: true/false. Default value: true. With the value true, the scripts are printed.

before/after:

With the before and after attributes, you can define content that is output before or after the content produced by the tag.

Allowed values: text that may contain HTML and Interface markup.

E.g.

  • before: '<p>This markup appears before the tag's own content.</p>'.
  • after: '<p>This appears after the tag's own content.</p>'

If the tag does not produce any content, the content of the before and after attributes will also not be displayed.

escape:

Adds an escape character before quotation marks in the output. The attribute makes it easier to process the tag-produced content when using JavaScript.

Allowed values: true/false. The default value is false.

or:

Defines alternative content that is displayed if the tag itself does not produce any content.

Allowed values: text that may contain HTML and Interface markup.

E.g. or:'Content not found.'