Removing javascript/css from page header

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Locked
krems04
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Mon Jan 05, 2009 4:45 pm

Removing javascript/css from page header

Post by krems04 » Thu Oct 28, 2010 4:14 pm

hey people

Im creating a mobile template and i'd like to remove as much unecessary requests in the page header as possible, notably for

-JCEMediabox (css & js)
-Floatbox.js
-Other javascript code that gets loaded into the page from the GMapFP component

i tried modifying some code i found in the forums, but to no avail. notably

Code: Select all

JHTML::_('behavior.mootools');
if ($option == 'com_comprofiler') {
  $headerstuff = $this->getHeadData();
  $key = JURI::base( true ) . '/media/system/js/mootools.js';
  unset( $headerstuff['scripts'][$key] );
  $this->setHeadData( $headerstuff );
}

Anyone has any ideas?

krems04
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Mon Jan 05, 2009 4:45 pm

Re: Removing javascript/css from page header

Post by krems04 » Fri Apr 29, 2011 3:34 pm

ended up solving problem myself by hacking the relevant components :-[ (in this case, GMAPfp & Docman.

basically, in the component code, before the CSS declarations, you can drop this bit of code in

Code: Select all


$app = & JFactory::getApplication();
$template = $app->getTemplate();

if ($template == 'name of template you want to remove js/css from ') {
return;
}

krems04
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Mon Jan 05, 2009 4:45 pm

Re: Removing javascript/css from page header

Post by krems04 » Thu Sep 20, 2012 4:14 pm

just posting this for information purposes! :D

Extension hacking no longer needed, there are two ways of getting around this


1) From your template.

Code: Select all

<?php
//Only call these if required, helps combat conflicts and load times
 
//can also be used to remove Mootools
 
 
unset($this->_scripts[$this->baseurl .'/media/system/js/mootools.js']);
unset($this->_scripts[$this->baseurl .'/media/system/js/caption.js']);
unset($this->_scripts[$this->baseurl .'/media/system/js/mootools-more.js']);
unset($this->_scripts[$this->baseurl .'/components/com_something/javascriptfile.js']);

//works for CSS too 


unset($this->_styleSheets[$this->baseurl .'/modules/mod_something/css/randomcssfile.css']);



?>

I posted it here...

http://www.jsnippets.net/snippets/php/r ... r-template



and 2) A rather amazing plugin on the JED that lets you override anything from components and modules. models, controllers, helpers, whatever :D

http://extensions.joomla.org/extensions ... I7fQ%3D%3D


Locked

Return to “Joomla! 1.5 Coding”