How to remove CSS 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 CSS files which are being loaded in a site's HEADER. It'll help you to merge all these CSS files into one CSS file. In this case you're able to remove unwanted CSS files from being loaded. You'll have to code a system plugin for the purpose and add the following php code.
Insert these php lines below into onBeforeRender Joomla system event to handle it:
function onBeforeRender(){ //remove scripts for Joomla FrontEnd only if ( !JFactory::getApplication()->isAdmin() ) { $scripts = JFactory::getDocument()->_styleSheets; $scripts = array_keys( $scripts ); //removing widgetkit.css if( strpos( $script, 'widgetkit' ) ) { unset( JFactory::getDocument()->_scripts[$script] ); } //removing fancybox.css if( strpos( $script, 'fancybox' ) ) { unset( JFactory::getDocument()->_scripts[$script] ); } } }
So this way, adding any CSS file name you can easily prevent this CSS file from being loading into your site's HEADER tag: //removing scriptname.css if( strpos( $script, 'scriptname' ) ) { unset( JFactory::getDocument()->_scripts[$script] ); }

Joomla Articles