-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove default colors #24684
Comments
Hi @rilwis, Themes don't need to define support for these colors. If the theme does not use any color functionality at all these default colors will appear in the color palette. Thank you in advance for further information! |
Hi @jorgefilipecosta , In my case, our theme has a custom color palette (different from default). And the default colors don't appear in the edit page, which is correct. However, the CSS is still in the outputted CSS of Gutenberg, which causes these issues:
|
I'm thinking that we could probably remove all these custom colors from the hardcoded stylesheets, and instead create them dynamically. But then that brings up another interesting point: |
I think Gutenberd shouldn't add default color palette at all. Let themes do that via If users switch to another themes, then they should know that themes use different color palette and thus, the old color palette might not be applied. |
@aristath yes, that's an idea we explored previously with @jorgefilipecosta (auto-generated the palette styles) and i think it's something we should revisit when we move all the presets definitions to theme.json. |
Update: Still applicable in Gutenberg 12.4.3; WordPress 5.9 Goal/Issue: Do not include the CSS for gradients when these presets are disabled within the theme. I found this issue because I was about to create an issue for this same problem, the problem that @rilwis is referring is that the Global/default CSS colors are defined and included inline in your html even when you disable them in the theme support hook or through the theme.json To reproduce:
Or its equivalent rules in a theme.json file.
(Feb. 2022: (In July 2021: |
Hi, note that this is the expected behavior. The idea is that the core colors are always available in CSS (only for themes with There're two reasons for this: one is patterns, and having a system that works across themes; the other is that there's plans to redesign the color component to show core, theme, and user colors. #29568 is the relevant issue and I'd welcome comments on it, so others that follow it can see them as well. I'd think we can close this issue as discusses things that are already in #29568 and the behavior is expected. |
This is a performance enhancement. If you want to disable inlining small assets, try adding this: add_filter( 'styles_inline_size_limit', '__return_zero' ); You can read more in this article: https://make.wordpress.org/core/2021/07/01/block-styles-loading-enhancements-in-wordpress-5-8/ |
Thank you for this input @aristath. That would be sufficient for me, however I can not get it to work. I tried both the snippet above, and the alternative To no avail. Let me clarify, that this block of inline styling first occurred on my WordPress 5.9 RC2/3 test installation. I'm not seeing it on my WordPress 5.8 sites. And while I'm aware, that inlining small bits of styling makes great sense performance wise, I'm using brand colours for all my sites, not WordPress core colours, and I have a hard time grasping how beginning to load unused colour-styles inline, is a performance enhancement. I only see 8 kb of additional overhead since installing WP 5.9. I'm not complaining. There is obviously something I don't understand, and I'd prefer to. My WP 5.9 test site is https://oldrup.net/, should anyone have an idea what I'm doing wrong. |
Ah perhaps I misunderstood the issue then. I thought the comment above was about the fact that the styles get inlined as opposed to enqueued as a stylesheet. {
"settings": {
"color": {
"defaultPalette": false,
"defaultGradients": false
}
}
} |
Thank you, @aristath. I attempted this approach both in my child theme folder and on the parent theme, with theme.json version 1 and 2, but was unable to succeed in removing the inline styling. I have no prior experience with configuring themes using .json, and it is clear to me that I need that first. Thank you for giving me some direction. |
Following @oldrup from his question over on wordpress.org topic in the event this is helpful to others. You can remove the Gutenberg theme library on the front-end (if not necessary) along with the inline injection, and save an additional 77.3KB in the DOM. As well as address WooComm variant with the following code in your functions.php: //REMOVE GUTENBERG BLOCK LIBRARY CSS FROM LOADING ON FRONTEND Alternatively, you can just remove the inline style injection with the following (but this will NOT remove the block library stylesheet but rather the global variables that are injected inline): // DISABLE GUTENBERG STYLE IN HEADER - WORDPRESS 5.9 |
Going to close this issue out based on the above dialogue and resolutions! In case it's helpful to more folks, wanted to flag the following sentence from this post:
If this needs to be re-opened for some reason, please just comment :) For now, seems best to continue the discussion here: #29568 |
For anyone that finds this issue before others, a working solution is this filter:
I wish I had found this issue before digging for a while to find it, since the solution I came up with was already there ;P Basically, these properties are there for backwards compatibility. For new sites, I'll be running this filter for the foreseeable future. |
I see Gutenberg included quite a lot of default colors in the CSS:
They're available in the CSS files only, but not in the color palette when editing posts. To make them appear in the color palette, themes must define support for those colors. But in that case, themes still need to add their own CSS to make sure they work properly.
So, it's redundant to keep the CSS in the Gutenberg CSS to keep things minimal. There's also some config in the
block-editor.js
file that reflects these colors as well.The text was updated successfully, but these errors were encountered: