How to make js file load asynchronously in joomla template file

1k Views Asked by At

I am using joomla. In it's template js are being called like following way-

 $doc->addScript($this->baseurl . '/templates/' . $this->template . '/javascript/cscript.js', 'text/javascript');

I just want to add tag async to it. How should i do that..??

1

There are 1 best solutions below

3
On BEST ANSWER

You need to pass 4th param with boolean true,

$doc->addScript($this->baseurl . '/templates/' . $this->template . '/javascript/cscript.js', 'text/javascript', false, true);