admin管理员组文章数量:1122846
I like to know how I can remove these individually.
<style id='wp-block-separator-inline-css'>
@charset "UTF-8";.wp-block-separator{border-bottom:1px soli ...
</style>
WP has a feature to add inline JS and (and also CSS I think) to registered scripts/styles. So dequeue should work, but it does not.
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\action_wp_enqueue_scripts', 99 );
function action_wp_enqueue_scripts() {
wp_dequeue_style( 'wp-block-navigation' ); // Comes from a file and works
wp_dequeue_style( 'wp-block-post-comments-form' ); // Comes from a file and works
wp_dequeue_style( 'wp-block-seperator' ); // Does not work
}
A hint to where exactly I find in the source on how these are handled would also help.
And BTW, I do not understand why these are handled in this stupid HTML polluting way in the first place. This does not seem to be dynamic for the most part, but FSE Themes are spammed with inline CSS for almost all blocks, only a few are loaded from CSS files. This causes the browser to never cache the CSS for blocks, very inefficient.
Asked the question and made this comment already on Github.
I like to know how I can remove these individually.
<style id='wp-block-separator-inline-css'>
@charset "UTF-8";.wp-block-separator{border-bottom:1px soli ...
</style>
WP has a feature to add inline JS and (and also CSS I think) to registered scripts/styles. So dequeue should work, but it does not.
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\action_wp_enqueue_scripts', 99 );
function action_wp_enqueue_scripts() {
wp_dequeue_style( 'wp-block-navigation' ); // Comes from a file and works
wp_dequeue_style( 'wp-block-post-comments-form' ); // Comes from a file and works
wp_dequeue_style( 'wp-block-seperator' ); // Does not work
}
A hint to where exactly I find in the source on how these are handled would also help.
And BTW, I do not understand why these are handled in this stupid HTML polluting way in the first place. This does not seem to be dynamic for the most part, but FSE Themes are spammed with inline CSS for almost all blocks, only a few are loaded from CSS files. This causes the browser to never cache the CSS for blocks, very inefficient.
Asked the question and made this comment already on Github.
Share Improve this question edited May 17, 2022 at 13:10 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked May 16, 2022 at 9:26 NextGenThemesNextGenThemes 7357 silver badges28 bronze badges 6 | Show 1 more comment1 Answer
Reset to default 1To get it off the unanswered list, adding the comment by @Sally CJ as answer:
There was a typo, it's separator not seperator. This works:
add_action( 'wp_enqueue_scripts', 'mytheme_wp_enqueue_scripts', 99 );
function mytheme_wp_enqueue_scripts() {
wp_dequeue_style( 'wp-block-separator' );
}
本文标签: How to stop Gutenberg from outputting inline CSS for specific blocks
版权声明:本文标题:How to stop Gutenberg from outputting inline CSS for specific blocks? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736304482a1932250.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
theme.json
to set these parameters – Tom J Nowell ♦ Commented May 16, 2022 at 9:36wp_dequeue_style( 'wp-block-separator' );
? – Sally CJ Commented May 18, 2022 at 7:55