Skip to content

Instantly share code, notes, and snippets.

@rdeutz
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdeutz/6ab0af53cf2ca8c4c242 to your computer and use it in GitHub Desktop.
Save rdeutz/6ab0af53cf2ca8c4c242 to your computer and use it in GitHub Desktop.
removing scripts from the head
// 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