backdrop / backdrop-issues

Issue tracker for Backdrop core.
144 stars 40 forks source link

To remove list of styles links from head #1253

Open bd0bd opened 9 years ago

bd0bd commented 9 years ago

For me it is not beautiful to have such a big list of links if I need only one or two css files. Could you please tell me how to remove it from head?:

<style media="all">
@import url("http://my-domain.com/core/misc/normalize.css?nv7dmp");
@import url("http://my-domain.com/core/modules/system/css/system.css?nv7dmp");
@import url("http://my-domain.com/core/modules/system/css/system.theme.css?nv7dmp");
</style>
<style media="all">
@import url("http://my-domain.com/core/modules/comment/css/comment.css?nv7dmp");
@import url("http://my-domain.com/core/modules/field/css/field.css?nv7dmp");
@import url("http://my-domain.com/core/modules/user/css/user.css?nv7dmp");
@import url("http://my-domain.com/core/modules/views/css/views.css?nv7dmp");
</style>
<style media="all">
@import url("http://my-domain.com/layouts/my_one_column/my-one-column.css?nv7dmp");
</style>
<style media="all">
@import url("http://my-domain.com/themes/bartik/css/style.css?nv7dmp");
@import url("http://my-domain.com/files/color/bartik-1eb08e49/colors.css?nv7dmp");
</style>
<style media="print">
@import url("http://my-domain.com/themes/bartik/css/print.css?nv7dmp");
</style>

Thank you!

quicksketch commented 9 years ago

You can remove any CSS file from displaying in your theme by adding a line in your theme .info file:

stylesheets[] = system.theme.css

If you have that stylesheet in your theme, then your replacement version will be used. If you do not have that file in your theme, nothing will replace it and the original file will just simply be suppressed.

Note that removing CSS files may cause some functionality to break. In particular, you shouldn't remove the system.css file, otherwise things like collapsed fieldset, vertical tabs, contextual links, and other system-provided functionality will stop working.

As an aside, you may also want to turn on CSS aggregation under the Configuration > Development > Performance page. Then each of the stylesheets within a group will be compressed into a single stylesheet. But I can understand if this is a site cleanliness issue rather than a performance issue. Due to the modular component of Backdrop, it's very common that each module you enable will also come with an additional front-end stylesheet.

bd0bd commented 9 years ago

@quicksketch, thank you!

I can understand if this is a site cleanliness issue

Yes! Nothing else.

clickbox commented 8 years ago

I'm not having any luck with disabling core CSS by "enabling" it in the theme's .info file. The function hook_css_alter seems to be the alternative?