Stop Loading Automatic Scripts in Joomla 2.5

joomla

Solution

I would not recommend you to change the core files of Joomla.But if you really need to that then you can try this:

Step to disable the preloaded script file in joomla template.

Step one: Using your favorite file editor, open for edit:

/libraries/joomla/document/html/renderer/head.php

Step one: Find this code at line 151 and update it to include the code with this :

// Generate script file links
foreach ($document->_scripts as $strSrc => $strAttr)
{
    // Code to disable mootools for your site (still loads it for your admin)

    $ex_src = explode("/",$strSrc);
    $js_file_name = $ex_src[count($ex_src)-1];
    $js_to_ignore = array("mootools-core.js","mootools-more.js","core.js","caption.js");
    if( in_array($js_file_name,$js_to_ignore) AND substr_count($document->baseurl,"/administrator") < 1 AND $_GET['view'] != 'form')
        continue;

    $buffer .= $tab . '<script src="' . $strSrc . '"';
    if (!is_null($strAttr['mime']))
    {
        $buffer .= ' type="' . $strAttr['mime'] . '"';
    }
    if ($strAttr['defer'])
    {
        $buffer .= ' defer="defer"';
    }
    if ($strAttr['async'])
    {
        $buffer .= ' async="async"';
    }
    $buffer .= '</script>' . $lnEnd;
}

After saving the changes above, clear the cache that you have set and test your Joomla website and your Joomla Admin Dashboard. If you view the source code,all the predefind files are not there.

Or

You can try like this to hide it from `index.php` in template. Just put this line before the `<jdoc:include type="head" />` and make necessary changes as needed to the scripts.

<?php 
    $search = array('mootools-more.js', 'caption.js');
    // remove the js files
    foreach($this->_scripts as $key => $script) {
        foreach($search as $findme) {
            if(stristr($key, $findme) !== false) {
                unset($this->_scripts[$key]);
            }
        }
    }
?>

Problem

In `Joomla 2.5`, the scripts below are loaded automatically. ``` <script src="/media/system/js/mootools-core.js" type="text/javascript"></script> <script src="/media/system/js/core.js" type="text/javascript"></script> <script src="/media/system/js/caption.js" type="text/javascript"></script> <script src="/media/system/js/mootools-more.js" type="text/javascript"></script> <script src="/templates/pswedge/js/jquery.min.js" type="text/javascript" defer="defer"></script> ``` I don't want to load these files. How can I remove these links?

Original source