Skip to content

rishiv3/joomla-adding-javascript-file-in-the-footer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 

Repository files navigation

Javascript files includes in footer

  1. Create a new file called footer.php in /libraries/joomla/document/html/renderer/ directory:

  2. In /libraries/joomla/document/document.php add after

    public $_scripts = array();
    this
    public $_footer_scripts = array();

  3. Add method addFooterScript() after the addScript() method

    function addFooterScript($url, $type = "text/javascript", $defer = false, $async = false) {
    	$this->_footer_scripts[$url]['mime'] = $type;
    	$this->_footer_scripts[$url]['defer'] = $defer;
    	$this->_footer_scripts[$url]['async'] = $async;
    	return $this;
     }
  4. In index.php in you template folder add just before the tag

    <jdoc:include type="footer" />
    
  5. Done!
    Now in layouts inside your template's folder you can use the following code to add javascript files to footer:

    $doc =& JFactory::getDocument();
    $doc->addFooterScript('JavaScript_File_Path.js');
    

TODO : check for updates...

About

Javascript files includes in footer

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages