Joomla: Removing Mootools from the frontend and optimising your site

A simple one today, one simple way to slightly optimise you Joomla installation. You will notice when using YSlow and other optimisation tools that it suggests including less javascript files. Http requests to the same server can only return one file at a time and only one request can be made to the same server at the same time. That is why using a Content Delivery Network (CDN) can prove useful, as well as feeding images and videos from Flickr and YouTube, not to mention the costs saved on bandwidth. Anyway, the less request you have to make, the faster your site will load.
The below code, added to the top of you Joomla template should remove the sometimes unnecessary Mootools javascript inclusions. Be sure you are not using them. If you notice that you have squeezebox included on your page, something I have noticed on a number of forum threads, it will be due to another extension you are running and not part of the Joomla core. Hope its helpful!
// remove mootools
$headerstuff = $this->getHeadData();
$scripts = $headerstuff['scripts'];
foreach ($scripts as $path => $val){
if (strpos($path, ‘core.js’) !== false || strpos($path, ‘modal.js’) !== false || strpos($path, ‘caption.js’) !== false || strpos($path, ‘mootools-more.js’) !== false){
unset($scripts[$path]);
}
}
$headerstuff['scripts'] = $scripts;
$this->setHeadData($headerstuff);