Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

joomla- How to remove unwanted js files from page

Tags:

php

joomla

joomla- How to remove unwanted js files from page

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

like image 928
Hunter Avatar asked May 21 '12 12:05

Hunter


1 Answers

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']); ?>
like image 103
Kristian Hildebrandt Avatar answered Sep 21 '22 13:09

Kristian Hildebrandt