public addJS ( string $uri, boolean $defer = false, boolean $async = false, string $version = null, string $type = 'text/javascript' ) : void | ||
$uri | string | A path definition understood by parsePath, e.g. media://com_example/js/foo.js |
$defer | boolean | Adds the defer attribute, see above |
$async | boolean | Adds the async attribute, see above |
$version | string | (optional) Version string to be added to the URL |
$type | string | MIME type of the script |
Résultat | void |
public function addJS($uri, $defer = false, $async = false, $version = null, $type = 'text/javascript')
{
if ($this->container->platform->isCli()) {
return;
}
$method = 'addScript' . (!empty($version) ? 'Version' : '');
$document = $this->container->platform->getDocument();
if (!method_exists($document, $method)) {
return;
}
$url = $this->container->template->parsePath($uri);
if (empty($version)) {
$document->addScript($url, $type, $defer, $async);
return;
}
$document->addScriptVersion($url, $version, $type, $defer, $async);
}