its a pita to always have to compress css files to test on ie for responsive etc.
so a setting to set the @import to instead use a <link> for css files

Comments

anthonyR’s picture

Don't mind for this feature to be added, but maybe a tip:
I do this when preprocessing in sass, most of my files are partials and get imported into one main stylesheet, and I only add that one to Drupal.

betovarg’s picture

Is there a reason why all the CSS files are set as @import? I was wondering that myself today while working on a subtheme

betovarg’s picture

:o, sorry about that last post. I now see that even Bartik adds the @import, havent noticed that in D7

msmithcti’s picture

To answer betovarg's question: As far as I'm aware it's not a theme specific thing, it's something that core does in D7 to get around IE ignoring any link/style tags after the 31st, which Drupal can easily get to when aggregation is turned off. #228818: IE: Stylesheets ignored after 31 link/style tags is the related core issue.

betovarg’s picture

Thanx splatio. After I posted this, been reading about that. Im actually quite concerned about that @import thing, Ive seen some sites not compressing their CSS. This is a discussion for other thread I guess, but I still think the practice is not good.

mortendk’s picture

Status: Active » Needs review

found a solution :)
* its only gonna be the theme's css files thats gonna use mediaqueries
* only the themes css is gonna be added in as link instead of an import, if the css compressions isnt turn on
* Only if the mothership is using Respond.js this will be executed

its all in the latest dev version in functions/css.php

  //test if aggregate isnt turned on and were using
  if ( !variable_get('preprocess_css') AND theme_get_setting('mothership_respondjs') ) {

    foreach ($css as $file => $value) {
      // only take the files in the theme that should prevent us from going oveor the 31 files
      if (strpos($file, 'themes') !== FALSE) {
        //ok test if the file exist just to not add css files that we killed of with FOAD
        //its not pretty but we dont have any easy methode to read theme_info from 2 level of basethemes
        //so this is what changes from @import to <link>
        //https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_add_css/7
        $count ="0";
        if(file_exists($file)){
          $css[$file]['preprocess'] = FALSE;
          $count++;
        }
      }
    }
    //test for the IE limit for 31 linked css files
    if($count > 31){
      drupal_set_message(t('IE 8/9 have a limit of 31 files  why are you adding that many css files in your theme ... use a preprocessor '), 'warning', FALSE);
    }
mortendk’s picture

Issue summary: View changes

Updated issue summary.