By harrvester on
My site imports many CSS files. I want to create a new theme. Are all of those CSS necessary ?
For example I don't want to incorporate any Search function in my design.
Can I delete: @import url("http://localhost/drupal/modules/search/search.css?lz5gsp"); ?
How ?
Also.. how can all the CSS files be merged in one single file ? Is there any module that can merge only specific CSS files ?
I now that CSS can be added to page with href and not with @import. How can I do something like :
<link type="text/css" rel="stylesheet" href="all_design_from_drupal.css" />
<link type="text/css" rel="stylesheet" href="all_my_custom_design.css" />Any recommendation on how to load the CSS files and keep the code clean ?
Comments
All CSS files load through
All CSS files load through the .info file. You can comment unnecessary CSS files there.
Add semicolon before those will not load .
;stylesheets[all][] = css/style.cssAnd also you can add specific CSS files inside the .module file .
drupal_add_css() can be used inside the template file as well.
Drupal loads CSS files
Drupal loads CSS files through the .info file. You can add CSS files following way.
stylesheets[all][] = css/style.cssYou can comment unnessary CSS files this way. Use semicolon.
;stylesheets[all][] = css/style.cssAnd also you can load CSS files through your .module file. This will load only for module.
drupal_add_css(drupal_get_path('module', 'module_name') .'/css/style.css', 'module');drupal_add_css() can be used inside the template file as well.
I don't use
I don't use drupal_add_css().
I only load one css file in .info and still I have something like this:
Hi Sir, Can I delete: @import
Hi Sir,
Can I delete: @import url("http://localhost/drupal/modules/search/search.css?lz5gsp"); ?
- Yes, you can use: hook_css_alter(&$css), and unset the css file you want to exclude.
how can all the CSS files be merged in one single file ?
- Go to Configuration > Performance, then below in Bandwidth optimization check Aggregate and compress CSS files.
thanks !With Aggregate and
thanks !
With Aggregate and compress CSS files my code reduced to:
But.. is it possible to go farther? Is it possible to have 1 CSS file ? Can I drop CDATA ? And.. except the nice, good looking code, is it worth to do any more optimization ?
Have you achieved it?
Hi harrvester
Im trying to compress all my CSS in only one file. Finally you find the way to do it?
Thanks!!!