cdn_asset

Calls an asset from the CDN

Examples

Javascript library:

[%cdn_asset html:'1' type:'js' version:'4.4.0' library:'skeletal' domain:'www.google.com'%]example.js[%/cdn_asset%]

CSS library:

[%cdn_asset html:'1' type:'css' library:'fancybox' version:'2.1.5'%]jquery.fancybox.css[%/cdn_asset%]

Default image:

[%cdn_asset html:'0' library:'images'%]default_product.gif[%/cdn_asset%]

Output results

Javascript library:

<script type="text/javascript" src="https://www.google.com/skeletal/4.4.0/example.js"></script>

CSS library:

<link rel="stylesheet" type="text/css" href="https://cdn.neto.com.au/assets/neto-cdn/fancybox/2.1.5/jquery.fancybox.css" media="all">

Default image:

https://cdn.neto.com.au/assets/neto-cdn/images/default_product.gif

Usage

The CDN asset tag will load either a CSS file, a JS file or default image from a location based on specified parameters

Parameters

Name Options Description
type:'' css, js Dictates whether the created tag will be a script tag or link tag
html:'' 1 / 0 A boolean that when true (1) will print script OR link tag depending on the type, while false (0) will print a link
domain:'' URL Uses //cdn.neto.com.au/assets/neto-cdn as a default, this determines the base domain to load the asset from. Beginning http: OR https: will be removed if they are in the domain. Ending backslashes ('/') will also be removed.
library:'' String The third last section in the URL, this is not required.
version:'' String The second last section in the URL, this is not required.

Options

type library domain version Filename
css use.fontawesome.com/releases v5.0.11 css/all.css
css fancybox 2.1.5 jquery.fancybox.css
js fancybox 2.1.5 jquery.fancybox.pack.js
js html5shiv 3.7.0 html5shiv.js
js jcountdown 1.4 jquery.jcountdown.min.js
js jquery_ui 1.11.1 js/jquery-ui-1.8.18.custom.min.js
js respond.js 1.3.0 respond.min.js
js skeletal 4.0.0 vendor.js
js zoom 1.4 jquery.zoom-min.js

Was this article useful?

Be notified when this page is updated. Optional.