Last active
August 29, 2015 14:15
removing scripts from the head
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// that is bad hack, I am accessing a by convention as private maked class variable. | |
// But you can not set the head to an empty array so that is the only way to allow to remove all scripts | |
// I am adding one script, this should have all the scripts merged into one file | |
// KEEP IN MIND THAT'S WORKING NOW (VERSION 3.3.6) BUT THAT DOES NOT MEAN IT WILL WORK ALWAYS | |
$tpath = $this->baseurl.'/templates/'.$this->template; | |
$scripts = $doc->_scripts; | |
$doc->_scripts = array(); | |
$doc->addScript($tpath.'/js/simple.js'); | |
$disabledScripts = $templateparams->get('fnjs'); | |
if (trim($disabledScripts) != '') | |
{ | |
$filesjs = array_map('trim', explode(',', $disabledScripts)); | |
foreach($scripts as $url => $styleParams) | |
{ | |
if (!in_array(basename($url), $filesjs)) | |
{ | |
$doc->addScript($url, $styleParams['mime'], $styleParams['defer'], $styleParams['async']); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment