1

I am trying to add a jquery plugin to a page through drupal_add_css and drupal_add_js as follows:

drupal_add_css($path = 'sites/all/libraries/gips/css/gips.css', $type = 'file', $media = 'all', $preprocess = true);
drupal_add_js('sites/all/libraries/gips/js/gips.js', array('type' => 'file', 'scope' => 'header', 'weight' => 3));
drupal_add_js("jQuery(document).ready(function(){...dosomething...});"), array('type' => 'inline', 'scope' => 'footer', 'weight' => 5));

When I'm not aggregating/caching the CSS files, it works fine. When I try to aggregate the CSS files, it doesn't. The behavior is as if some css rules get lost in the process. The same happens even if I change the $preprocess to false.

From Chrome's code inspector, I cannot see any overriding rules getting in the way either.

I am at a loss on how to debug this. Any suggestions?

3
  • 1
    Please take the time to accept the answers to your previous questions, people will be much more willing to help if you do :)
    – Clive
    Commented Feb 1, 2012 at 12:24
  • @Clive I am not sure which answers you are referring to. Is this a generic comment or you have something specific in mind? From what I looked, I have upvoted the answers I found useful.
    – nikan
    Commented Feb 1, 2012 at 12:49
  • 2
    @Clive Ahh! Much obliged. I wasn't aware of this. Will do right away!
    – nikan
    Commented Feb 1, 2012 at 13:25

2 Answers 2

7

While you are using the version 7 drupal_add_js, the snippet you posted appears to be using the Drupal 6 arguments for drupal_add_css. You might also need to set the every_page option to true so that it is aggregated. Maybe try:

drupal_add_css('sites/all/libraries/gips/css/gips.css', array('type' => 'file', 'media' => 'all', 'preprocess' => true, 'every_page' => true));

You could also have a look at the group and weight settings on the api page linked above to see if they will help.

0
0

For d7 with enabled aggregation needed 'preprocess' => FALSE for css and js: https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_add_css/7

1
  • While broadly helpful if this is coming up in Google, this specific question does say "even if I change the $preprocess to false"
    – John C
    Commented Jan 24, 2015 at 1:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.