ClassicPress
ClassicPress copied to clipboard
💡 Rename wp-tinymce.js to wp-tinymce.min.js
Context
The file wp-tinymce.js
, located in /wp-includes/js/tinymce/
, is currently named as unminified.
Yet the content is minified, because it combines the minified versions of the scripts /wp-includes/js/tinymce/tinymce.js
and /wp-includes/js/tinymce/plugins/compat3x/plugin.js
into one file.
Line 98 of /wp-includes/script-loader.php
determines if a compressed version should be loaded, but uses an uncompressed file extension for this.
Benefits of renaming this file:
- Using the correct file extension to align with coding standards.
-
min.js
files are excluded by default using the WP-CLI commandwp i18n make-pot
. - Prevents Memory Exhaust errors when creating a new
pot
file.
Possible implemantion
No response
Possible Solution
- Manually rename
/wp-includes/js/tinymce/wp-tinymce.js
to/wp-includes/js/tinymce/wp-tinymce.min.js
. - Minor code change in
/wp-includes/script-loader.php
, line 98.
From:
$scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.js', array(), $tinymce_version );
To:
$scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.min.js', array(), $tinymce_version );
Will you be able to help with the implementation?
signed up
This sounds like a good idea. I just did a quick test and TinyMCE seems to work fine.
However, we can't implement this until version 3 at the earliest. That's because it would be a breaking change, i.e. plugins and themes might be relying on this script, and won't find it if we change its name. Because we are following semantic versioning, we can't make a breaking change until the next major version of ClassicPress, which will be version 3.
But then there's also the question of whether ClassicPress will even still be using TinyMCE by the time we get to version 3. The current version of TinyMCE is very old and no longer maintained. We need to decide whether to update it to a newer version or to move to an alternative editor. There have been discussions about that on Zulip, but no decision has yet been taken. Feel free to try out Tiny v6, Toast UI, Quill.js, CKEditor, and others you come across to see if you have a preference.
I understand your concern about plugins and themes relying on this script, of course.
But since this script is already being registered using wp_default_packages
, those plugins and themes will simply use the wp-tinymce
handle. So, the chance of breaking a site seems very small to me.
Any change here would need to account for the build steps. wp-tinymce.js is a dynamic and built file created during core code build: https://github.com/ClassicPress/ClassicPress/blob/be5c1e8c20eacf38c6467f5798957628068de27c/Gruntfile.js#L759-L773
There is no unminified file and added a dynamic suffix for dev environments would not work.