3.10 Statistical Resources


Statistical resources, also called assets, are important to know when you are developing templates.

We have developed 2 help functions that are included in the resources:

  • addLink - This allows you to include CSS files, which are included in the section.
  • assScript - This allows you to include Javascript (JS) files, which are included in the bottom of the section.

The code can be used as follows:

*CODE* *SNIPPIT*
{addLink href='assets/css/libs.css'}
{addScript src='assets/js/custom.js'}
*CODE*

After which the template system finds and adds the static domain and path to the root of the template folder.

If you want to include an external file from another domain, you can by using an extra parameter called relative=true, which will tell the function that it should not create a static domain for the file:

*CODE* *SNIPPIT*
{addScript src='http://code.jquery.com/jquery-1.11.3.min.js' relative=true}
*CODE*

Domain for static resources

All static resources load via a separate "static" domain. This is done for several reasons:

  • Performance - The static domain is "cookie-less" and gives the possibility for quicker load through caching. It is also recommeded for e.g. Google to use this for static content.
  • SSL - The static domain always supports SSL.

Content used on multiple domains does not create problems for the search engine. e.g. Allows Google's Image Search to link to static domain content on the main domain.

The domain is found in this variable:

*CODE* *SNIPPIT* {$template.cdn}*CODE*

The static domain cannot be changed via the administration, but it is possible to overwritethe template level. It is not something we recommend.