Skip to content

Commit

Permalink
Perf: 禁用 Gutenberg 编辑器相关资源文件 (#560)
Browse files Browse the repository at this point in the history
  • Loading branch information
LuRenJiasWorld committed Apr 11, 2023
1 parent f6bfafd commit 47cbf8b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Front/FrontStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function __construct() {
$this->front_static_url = Config::get_option("editor_addres", "editor_style");

add_action("wp_enqueue_scripts", array($this, "enqueue_front_scripts"));
add_action("wp_enqueue_scripts", array($this, "dequeue_bloat_scripts"));
}

/**
Expand All @@ -55,10 +56,21 @@ public function enqueue_front_scripts() {
$jQueryName = "jQuery-CDN";
}

wp_enqueue_script("Front_Style", $this->front_static_url . "/assets/FrontStyle/frontstyle.min.js", array($jQueryName), $this->version, true);
wp_enqueue_style("Front_Style", $this->front_static_url . "/assets/FrontStyle/FrontStyle.min.css", array(), WP_EDITORMD_VER, "all");
wp_enqueue_script("Front_Style", $this->front_static_url . "/assets/FrontStyle/FrontStyle.min.js", array($jQueryName), $this->version, true);

wp_localize_script("Front_Style", "FrontStyle", array(
"openLinkInNewTab" => Config::get_option("open_in_new_tab", "editor_basics") // 在新标签页打开链接
));
}

/**
* 禁用不需要的脚本文件(Gutenberg引入)
* Ref issue: https://github.com/LuRenJiasWorld/WP-Editor.md/issues/560
*/
public function dequeue_bloat_scripts() {
wp_dequeue_style("wp-block-library");
wp_dequeue_style("wp-block-library-theme");
wp_dequeue_style("wc-blocks-style");
}
}

0 comments on commit 47cbf8b

Please sign in to comment.