joomla- How to remove unwanted js files from page

前端 未结 4 890
暖寄归人
暖寄归人 2020-12-15 23:08

joomla- How to remove unwanted js files from page

I have used plugins some pages so many js files are included in all pages

相关标签:
4条回答
  • 2020-12-15 23:28

    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.

    0 讨论(0)
  • 2020-12-15 23:31
    **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
    
    0 讨论(0)
  • 2020-12-15 23:33

    You can simply edit these plugins code to remove these files. or uninstall these plugins if not required.

    0 讨论(0)
  • 2020-12-15 23:46

    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']); ?>
    
    0 讨论(0)
提交回复
热议问题