Zum Inhalt

WordPress 禁用 block-library/style.min.css

WordPress 禁用 block-library/style.min.css

Google PageSpeed Insights 顯示的項目裡, 排除禁止轉譯的資源有 wp-includes/css/dist/block-library/style.min.css,禁用可以節省一點時間。

一些文章表示這個 css 大部分也用不上,所以就禁用看看吧!

在自定義插件裡加入以下代碼 (如何建立自定義插件: WordPress 建立支援 function.php 的自定義插件

// Function: Stop loading /wp-includes/css/dist/block-library/style.min.css
function gutenberg_style_disable() {
wp_dequeue_style( 'wp-block-library' ); }
add_action( 'wp_enqueue_scripts', 'gutenberg_style_disable', 100 );

之後,跑出了這樣的結果…..

禁用了一個,換來了兩個,以大小來看這兩個總量節省了 7 KiB左右,暫時就先放著吧。

資料參考: How to Remove Block Library CSS from WordPress 5.0

WordPress mit Classic Editor: block-library-CSS entfernen

Schlagwörter:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.