Reputation: 1601
joomla- How to remove unwanted js files from page
I have used plugins some pages so many js files are included in all pages
Upvotes: 15
Views: 23537
Reputation: 14544
If you want to remove all scripts that Joomla adds, including the inline script, the quickest way is this:
$this->_script = $this->_scripts = array();
Add this anywhere in your template file above the <head>
section.
Upvotes: 6
Reputation: 1528
There are two ways that I am aware of:
1) get an instance if the document object and remove the js files (you could do that in a plugin) :
<?php
//get the array containing all the script declarations
$document = JFactory::getDocument();
$headData = $document->getHeadData();
$scripts = $headData['scripts'];
//remove your script, i.e. mootools
unset($scripts['/media/system/js/mootools-core.js']);
unset($scripts['/media/system/js/mootools-more.js']);
$headData['scripts'] = $scripts;
$document->setHeadData($headData);
?>
2) remove js files directly from your templates index.php :
<?php unset($this->_scripts['/media/system/js/mootools-core.js']); ?>
Upvotes: 25
Reputation: 15
**An easiest way to disable mootools/ unwanted javascripts for your site in joomla cms ( 2.5 version )**(still loads it for your admin)
**Step-1:**
Using your favorite file editor, open for edit:
libraries/joomla/document/html/renderer/head.php
**Step-2:** check for code in head.php
// Generate script file links
foreach ($document->_scripts as $strSrc => $strAttr)
{
// *** start *** //
$ex_src = explode("/",$strSrc);
$js_file_name = $ex_src[count($ex_src)-1];
$js_to_ignore = array("mootools-more.js","core.js"); // scripts to skip loading
//skip loading scripts..
if( in_array($js_file_name,$js_to_ignore) AND substr_count($document->baseurl,"/administrator") < 1 AND $_GET['view'] != 'form'){continue;}
// *** end *** //
**Step-3:**
Clear cache & refresh page.
it works for sure.
For detailed explanation : http://www.inmotionhosting.com/support/edu/joomla-25/302-disable-mootools-in-joomla-25
Upvotes: -7
Reputation: 1153
You can simply edit these plugins code to remove these files. or uninstall these plugins if not required.
Upvotes: 0