Skip to content

Instantly share code, notes, and snippets.

@phproberto
Last active August 29, 2015 14:14
Show Gist options
  • Save phproberto/1cc224e5d41accfd3b77 to your computer and use it in GitHub Desktop.
Save phproberto/1cc224e5d41accfd3b77 to your computer and use it in GitHub Desktop.
Disable scripts inside joomla template
<?php
$doc = JFactory::getDocument();
// Supposes you have a template setting with name loadJquery
$loadJquery = $this->params->get('loadJquery', 1);
if ($loadJquery)
{
$removeJs = array(
'/jquery.min.js',
'/jquery.js',
'/jquery-noconflict.js',
'/jquery-migrate.min.js',
'/jquery-migrate.js',
'/bootstrap.min.js',
'/bootstrap.js',
);
$scripts = $doc->_scripts;
foreach ($removeJs as $removeScript)
{
foreach ($scripts as $script => $scriptdata)
{
if (stristr($script, $removeScript))
{
unset($scripts[$script]);
}
}
}
$doc->_scripts = $scripts;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment