I have an easy question for you. I got a paid template on my website and I want the js files loading with async attribute on page.
// add scripts
$this['asset']->addFile('js', 'js:uikit.js');
/* $this['asset']->addFile('js','warp:vendor/uikit/js/components/autocomplete.js');
$this['asset']->addFile('js', 'warp:vendor/uikit/js/components/search.js'); */
$this['asset']->addFile('js', 'warp:vendor/uikit/js/components/sticky.js');
/* $this['asset']->addFile('js', 'warp:vendor/uikit/js/components/tooltip.js'); */
$this['asset']->addFile('js', 'js:social.js');
$this['asset']->addFile('js', 'js:theme.js');
// internet explorer
if ($this['useragent']->browser() == 'msie') {
$head[] = sprintf('<!--[if IE 8]><link rel="stylesheet" href="%s"><![endif]-->', $this['path']->url('css:ie8.css'));
$head[] = sprintf('<!--[if IE 9]><link rel="stylesheet" href="%s"><![endif]-->', $this['path']->url('css:ie9.css'));
$head[] = sprintf('<!--[if lte IE 8]><script async src="%s"></script><![endif]-->', $this['path']->url('js:html5.js'));
}
if (isset($head)) {
$this['template']->set('head', implode("\n", $head));
}
and the other file:
$warp = require(JPATH_ROOT.'/templates/'.$this->form->getValue('template').'/warp.php');
$warp['system']->document->addScript($warp['path']->url('warp:vendor/jquery/jquery-mustache.js'));
$warp['system']->document->addScript($warp['path']->url('warp:vendor/jquery/jquery-cookie.js'));
$warp['system']->document->addScript($warp['path']->url('warp:vendor/jquery/jquery-less.js'));
$warp['system']->document->addScript($warp['path']->url('warp:vendor/jquery/jquery-rtl.js'));
$warp['system']->document->addScript($warp['path']->url('warp:vendor/spectrum/spectrum.js'));
$warp['system']->document->addScript($warp['path']->url('warp:vendor/uikit/js/uikit.js'));
$warp['system']->document->addScript($warp['path']->url('warp:vendor/less/less.js'));
$warp['system']->document->addScript($warp['path']->url('config:js/config.js'));
$warp['system']->document->addScript($warp['path']->url('config:js/admin.js'));
What should I add to have all or some of the js files can have async attribute?
Thanks