A little bit of optimization for plug-in performance.
Quote from 风起云落 on November 1, 2017, 4:55 pm
Mainly the visual editor, first of all I generally use WordPress is to directly disable the visual editor, used people know that will load a lot of js files and css files.
Plugin default to use the visual editor, may be used to facilitate the use of others, but it is to reduce the performance, I just read the official forum, the post page will load 40 js file ……… I first said , My WordPress site only loaded two js file, one is jq, one is their own js file, so 40 js loaded for me is simply astronomical number. And css file loading seems to have 13, but also Drunk drunk.Do it yourself, get enough food and find ways to solve this problem
First in the WordPress theme file functions.php which add the following code, in fact, I suggest that another registered plug-in to get it.
//修改论坛默认编辑器 function change_editor_settings($settings) { $settings['teeny'] = false; $settings['quicktags'] = true; $settings['quicktags'] = array('buttons' => 'strong,em,del,img,ul,ol,li,code'); return $settings; } add_filter('asgarosforum_filter_editor_settings', 'change_editor_settings'); //添加自定义编辑器按钮// function prettify_bottom($mce_settings) { if (!is_admin() && is_page('5087')) {//forum page id ?> <script type="text/javascript"> QTags.addButton( 'ah2', 'H2标题', "<h2>", "</h2>\n" ); QTags.addButton( 'alink', '链接', '<a href="">', '</a>' ); QTags.addButton( 'gtxt', '文本框', '<div class="alert alert-success" role="alert">\n可选择success,tip,error\n</div>', "" ); QTags.addButton( 'kkpre', '代码高亮', '<pre class="prettyprint linenums" >\n\n</pre>', "" ); </script> <?php } } add_action('after_wp_tiny_mce', 'prettify_bottom'); //彻底禁用可视化编辑器 add_filter('user_can_richedit','__return_false');This will be able to effectively reduce the js file and css file loading number, speed up the page speed, but! But! But there is a pit, that is, if you disable the visual editor, then the plug-in reference function will be invalid !!! The editor function is not defined, that is to say, you must open the visual editor.
Mainly the visual editor, first of all I generally use WordPress is to directly disable the visual editor, used people know that will load a lot of js files and css files.
Plugin default to use the visual editor, may be used to facilitate the use of others, but it is to reduce the performance, I just read the official forum, the post page will load 40 js file ……… I first said , My WordPress site only loaded two js file, one is jq, one is their own js file, so 40 js loaded for me is simply astronomical number. And css file loading seems to have 13, but also Drunk drunk.
Do it yourself, get enough food and find ways to solve this problem
First in the WordPress theme file functions.php which add the following code, in fact, I suggest that another registered plug-in to get it.
//修改论坛默认编辑器 function change_editor_settings($settings) { $settings['teeny'] = false; $settings['quicktags'] = true; $settings['quicktags'] = array('buttons' => 'strong,em,del,img,ul,ol,li,code'); return $settings; } add_filter('asgarosforum_filter_editor_settings', 'change_editor_settings'); //添加自定义编辑器按钮// function prettify_bottom($mce_settings) { if (!is_admin() && is_page('5087')) {//forum page id ?> <script type="text/javascript"> QTags.addButton( 'ah2', 'H2标题', "<h2>", "</h2>\n" ); QTags.addButton( 'alink', '链接', '<a href="">', '</a>' ); QTags.addButton( 'gtxt', '文本框', '<div class="alert alert-success" role="alert">\n可选择success,tip,error\n</div>', "" ); QTags.addButton( 'kkpre', '代码高亮', '<pre class="prettyprint linenums" >\n\n</pre>', "" ); </script> <?php } } add_action('after_wp_tiny_mce', 'prettify_bottom'); //彻底禁用可视化编辑器 add_filter('user_can_richedit','__return_false');
This will be able to effectively reduce the js file and css file loading number, speed up the page speed, but! But! But there is a pit, that is, if you disable the visual editor, then the plug-in reference function will be invalid !!! The editor function is not defined, that is to say, you must open the visual editor.
Uploaded files:Quote from 风起云落 on November 1, 2017, 5:03 pmSo that my website js load only 4, one of which is jq, css file load only 5, a total of 9 files, can be tolerated within the scope of my visitors that feel a lot faster, if your forum There will be a similar situation of low performance problems, it can be handled so.
So that my website js load only 4, one of which is jq, css file load only 5, a total of 9 files, can be tolerated within the scope of my visitors that feel a lot faster, if your forum There will be a similar situation of low performance problems, it can be handled so.
Uploaded files:Quote from Asgaros on November 2, 2017, 6:26 pmHello,
I am not really sure what I can do against it. I am using the default WordPress editor for this forum because it is integrated in WordPress by default and users should know how to use it. Thats why I dont want to implement another editor because a working one is already there.
I also dont do any big magic when using the editor in this plugin. Basically I only call the wp_editor() function and added a filter to modify the settings (which you are using in your example above). The rest is all completely done by WordPress core itself. I know that the editor is producing a lot of file requests but thats the way how the WordPress developed implemented it. And if you want to change something on it, it has to be done in the WordPress core.
Maybe you can try to suggest some improvements in the official WordPress core trac for at least reducing the number of requests when the editor is used. I dont want to do some magic in my plugin to change this behavior because this can have some significant affects to the admin area or other third-party plugins which maybe rely on the current behavior.
Hello,
I am not really sure what I can do against it. I am using the default WordPress editor for this forum because it is integrated in WordPress by default and users should know how to use it. Thats why I dont want to implement another editor because a working one is already there.
I also dont do any big magic when using the editor in this plugin. Basically I only call the wp_editor() function and added a filter to modify the settings (which you are using in your example above). The rest is all completely done by WordPress core itself. I know that the editor is producing a lot of file requests but thats the way how the WordPress developed implemented it. And if you want to change something on it, it has to be done in the WordPress core.
Maybe you can try to suggest some improvements in the official WordPress core trac for at least reducing the number of requests when the editor is used. I dont want to do some magic in my plugin to change this behavior because this can have some significant affects to the admin area or other third-party plugins which maybe rely on the current behavior.
Quote from 风起云落 on November 5, 2017, 4:15 amQuote from Asgaros on November 2, 2017, 6:26 pmI am not really sure what I can do against it. I am using the default WordPress editor for this forum because it is integrated in WordPress by default and users should know how to use it. Thats why I dont want to implement another editor because a working one is already there…
Yes, I know, this is not your plug-in problem, this pot should be WordPress official to back
Quote from Asgaros on November 2, 2017, 6:26 pmI am not really sure what I can do against it. I am using the default WordPress editor for this forum because it is integrated in WordPress by default and users should know how to use it. Thats why I dont want to implement another editor because a working one is already there…
Yes, I know, this is not your plug-in problem, this pot should be WordPress official to back