Search code examples
phpasynchronousjoomlacache-controlpagespeed

How to make js file load asynchronously in joomla template file


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..??


Solution

  • You need to pass 4th param with boolean true,

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