Answers:
如果您查看Joomla addScript
函数,它将显示以下内容:
public function addScript($url, $type = "text/javascript", $defer = false, $async = false)
{
$this->_scripts[$url]['mime'] = $type;
$this->_scripts[$url]['defer'] = $defer;
$this->_scripts[$url]['async'] = $async;
return $this;
}
$async
是布尔值,因此以下内容应为您工作:
$doc->addScript('//myscript.js', 'text/javascript', false, true);
该false
是$defer
和true
是$async