Joomla 1.5 is definitely a better CMS if you compare it to Joomla 1.0. One of few complaints I have heard and personally experienced with Joomla 1.5 is the inclusion of Mootools (and caption.js) by default if you use Joomla template method to display header information in your template. What’s the problem, one may ask? Well, the problem is that the Mootools file that comes with Joomla 1.5 is whopping 74k in size. From developer’s point of view, I may never need to use mootools in my application. And from end user point of view, this really slows down initial page load times especially for users who have slower connections, and you never get a second chance to make a first impression.Mootools is definitely a very useful JavaScript framework. (And since the perfectionist founder can even FIRE his developer, that also shows it has certain standard.) But loading it without using it really irritates some people.So why the hell on earth would Joomla 1.5 includes Mootools? The reason is because Joomla 1.5 Admin section uses Mootools. It’s the C (Controller) in the MVC (Model-View-Controller) that needs it. If you have installed the latest version and seen the AJAX effects from the admin area, you may probably know what I am talking about.Now the question is how to remove the Mootools and other JavaScript files from the header when the end users see it, and keep it exists when a administrator sees it? Don’t worry, here is the solution, below is the code I use to remove the mootools.js and caption.js
<?php
$user =& JFactory::getUser();
if ($user->get('guest') == 1) {
$headerstuff = $this->getHeadData();
$headerstuff['scripts'] = array();
$this->setHeadData($headerstuff); }
?>
<jdoc:include type="head" />
In case you want to keep the caption.js, (some Joomla! components, modules or plugins uses caption.js, for example:Acajoom), you can choose to remove mootools only. Below is the PHP code i use to do so:
<?php // Remove auto generated mootool from header $headerstuff = $this->getHeadData(); reset($headerstuff['scripts']); $moo = key($headerstuff['scripts']); unset($headerstuff['scripts'][$moo]); $this->setHeadData($headerstuff); ?> <jdoc:include type="head">
Hope these tips help!





















































#1 by TheMechE on May 22, 2009 - 10:38 am
Was having the same problem. Researched several sites. This guy seems to have wrapped that solution, in a module that you can install and click. No php edit required. Thanks for the solution though.. I saved me till I found this.
http://www.kinesphere.fr/mootools-control
#2 by marksu on June 16, 2009 - 12:02 pm
Well code did not work for me at backend.
Anyways strange code as it just removes first js file from the memory what ever it hapends to be.
I got the backend working using following code.
get(’guest’) == 1 or $user->usertype == ‘Registered’ or $user->usertype == ‘Super Administrator’) {
$headerstuff = $this->getHeadData();
//reset($headerstuff['scripts']);
//$moo = key($headerstuff['scripts']);
unset($headerstuff['scripts']['/media/system/js/mootools-uncompressed.js']);
$this->setHeadData($headerstuff);
}
?>
#3 by DEELL on June 24, 2009 - 5:29 am
Worked perfectly and was exactly what I needed. Many Thanks!!!
#4 by joe on June 30, 2009 - 7:35 am
Hi all,
Is there a way to use this only at one page in the back-end of joomla? Because i get a weird conflict with mootools if i want to add a new product. So i want to remove it only at this specific page.
Hope u guys can help me out here!
grtz
#5 by Sam on July 8, 2009 - 3:50 pm
Is there any way of specifically removing mootools? As it is now it’s just removing the first script, which in my case happens to be something else.
#6 by adnan on July 20, 2009 - 11:53 pm
That worked great. Thanks for the code. But for the first code will it work only for guest users? what will happen when a fornt-end user log in ??
#7 by Matt on August 24, 2009 - 9:28 pm
This mootools is also an issue when using the jquery library anywhere in joomla. I am using the galleriffic plugin, which is awesome, and it would not work until I applied your fix – thanks so much!
#8 by sandrar on September 10, 2009 - 7:17 am
Hi! I was surfing and found your blog post… nice! I love your blog. :) Cheers! Sandra. R.
#9 by angelina jolie on September 10, 2009 - 9:19 am
I love your site. :) Love design!!! I just came across your blog and wanted to say that I’ve really enjoyed browsing your blog posts. Sign: ndsam
#10 by megan fox on September 11, 2009 - 8:47 am
Sign: umsun Hello!!! rcuwwymhyw and 4177ssgfhphzye and 4113Cooooool blog really
#11 by Paul @ Web Design Ireland on October 28, 2009 - 3:54 am
Thanks for that – saved me some hassle!
#12 by Marcel Dullaart on October 30, 2009 - 4:17 am
Thanks for this information. I have an issue with another priece of javascript injected in the head section. This is a script section not a source reference.
To remove this I’d like to know where it is injected from. Do you know how these pieces of code get injected in the first place? I know the injects it, but that’s the end of the chain, there must be something from a module or component that registers information to be injected in the head.
Thanks,
Marcel
#13 by bben on December 11, 2009 - 8:14 pm
thank you for the tips!!!
#14 by tora on January 12, 2010 - 8:33 pm
hello,
having the same problem with mootools.js,
what is the name of the file to put this code?
hope quick response..
thx
#15 by Ganar on January 14, 2010 - 2:54 pm
the submission in message #1 works like a charm and allows for more flexibility
http://www.kinesphere.fr/mootools-control
I changed the code a little bit but is a great option when you have multiple templates in a project
#16 by Kris on February 8, 2010 - 10:27 pm
Thanks! this code worked perfectly for me. all I did was copy and paste it to replace the and it worked!! :D