Unnecessary files (css files) are being loaded..

errorist - June 11, 2009 - 05:35

How can I prevent unnecessary files to be loaded. e.g. in my classifieds module I can see css files loaded that are residing in events module.???

The css files that are only for event module should not load with other modules. Its making my website very slow.

Drupal is database driven.

coreyp_1 - June 11, 2009 - 06:14

Drupal is database driven. Trust me, it is the database server that makes your site slow, not the serving of static files (i.e., css).

That being said, you have several options.

  1. Enable CSS compression in your Site Performance menu.
  2. Override the CSS in your theme. info here
  3. Use Style Stripper.

-Corey

- Corey

and if i want to do this

momper - June 30, 2009 - 17:34

and if i want to do this handcoded - not with a module?
and i first want to remove 90% of all modules css files and then use the compression ...

is there stuff i can do in the xxx.info or template.php file?

thanks momper

There's a several different

coreyp_1 - June 30, 2009 - 21:26

There's a several different ways that css files can be added, but hacking the .info or module files is bad practice.

You could use your custom theme to filter the css files included, either by adding a preprocess function or by explicitly including files in your page template.

I would still use the module route.

-Corey

- Corey

in template.php for

momper - July 7, 2009 - 11:35

in template.php for example

/**
* Override or insert PHPTemplate variables into the templates.
*/
function phptemplate_preprocess_page(&$vars) {

  // Unset stylesheets.
  $css = $vars['css'];
    unset($css['all']['module']['modules/node/node.css']);
    unset($css['all']['module']['sites/all/modules/users/logintoboggan/logintoboggan.css']);
    unset($css['all']['module']['sites/all/modules/voting/fivestar/css/fivestar.css']);
    unset($css['all']['module']['sites/default/files/fivestar/basic/basic.css']);
    unset($css['all']['module']['sites/all/modules/views/views_cloud/views_cloud.css']);
    unset($css['all']['module']['sites/all/modules/js/jcarousel/jcarousel.css']);
    unset($css['all']['module']['sites/all/modules/js/jcarousel/jcarousel/lib/jquery.jcarousel.css']);
    unset($css['all']['module']['sites/all/modules/views/flag/theme/flag.css']);
    unset($css['all']['theme']['themes/kiezblogs/_css/jcarousel/skin.css']);
    $vars['styles'] = drupal_get_css($css);
}

 
 

Drupal is a registered trademark of Dries Buytaert.