How to remove JavaScript from Joomla header
Very, very hard coding and rude! But it works...
When you optimize your site for Google Search engine or other engines it's a good practice to reduce a number of javascripts which are being loaded in a site's HEADER tag. It'll help you to merge all these scripts into one javascript file.
If you don't plan to use Mootools on your site you can remove it as well. But be aware of JS errors as Joomla tries to use Mootools and you'll need to care about to remove a couple of strings from Joomla source files.
In this case you're able to remove unwanted scripts from being loaded. You'll have to code a system plugin for the purpose and add the following php code.
You can use the onBeforeRender Joomla system event to handle it:
So this way, adding any script name you can easily prevent this script from being loading into your site's HEADER tag:
//removing scriptname.js
if( strpos( $script, 'scriptname' ) ) {
unset( JFactory::getDocument()->_scripts[$script] );
}