Hi , I would like to add defer tag in script ...
I tried in Widget.php....
protected function resourceSettings()
{
//This function will be overwritten
// return array(
// "libraries"=>array("jQuery")
// "folder"=>null,
// "css"=>array(),
// "js"=>array(),
// );
return null;
}
public function renderResources($settings=null,$return=false)
{
if($settings==null)
{
$settings = $this->resourceSettings();
}
else if(gettype($settings)=="boolean")
{
$return = $settings;
$settings = $this->resourceSettings();
}
if($settings && isset($settings["folder"]))
{
$this->getAssetManager()->publish($settings["folder"]);
$css = Utility::get($settings,"css",array());
$js = Utility::get($settings,"js",array());
$library = Utility::get($settings,"library",array());
$html = "";
foreach($library as $libName)
{
switch(strtolower($libName))
{
case "jquery":
$publicAssetUrl = $this->getReport()->publishAssetFolder(realpath(dirname(__FILE__)."/../clients/jquery"));
$html.= str_replace("{jsUrl}",$publicAssetUrl."/jquery.min.js","<script src='{jsUrl}' type='text/javascript' defer></script>");
break;
}
}
foreach($css as $cssFile)
{
$html.= str_replace("{cssUrl}",$this->getAssetManager()->getAssetUrl($cssFile),"<link href='{cssUrl}' rel='stylesheet' type='text/css'></link>");
}
foreach($js as $jsFile)
{
$html.= str_replace("{jsUrl}",$this->getAssetManager()->getAssetUrl($jsFile),"<script src='{jsUrl}' type='text/javascript' defer></script>");
}
if($return)
{
return $html;
}
else
{
echo $html;
}
}
}
but its not showed when I view page source .......