commonWP
commonWP copied to clipboard
Minified Fetching
Taken from https://wordpress.org/support/topic/minified-2/
Is it possible to fetch minified versions of the files?
Cross-posted from linked thread for reference.
First, note that this feature wasn’t there during development of commonWP, it was enabled just last week.
There are some things to consider. Like I wrote when explaining how plugin works in its READMEs, it compares local file and remote file (file on jsDelivr) if they are identical. When there is minified file only on jsDelivr, there can’t be comparison because there is no local minified file.
Because of the way automatic minification on jsDelivr works, minified file can be larger than original in some cases. For example, files might not show in their name that they are already minified. jsDelivr will insert its header and that will make new file bigger. Example: original, automatically minified. Or, for JavaScript files, jsDelivr will insert both header and sourcemaps information, and if original file is already small, minified might be larger. Example: original, automatically minified. Or, when applying compression, for small files difference might be minor, just tens of bytes. Example with brotli: original, automatically minified.
Also, it is recommended by jsDelivr to not use subresource integrity when doing minification.
I can’t enable this by default, because I can’t be 100% sure that automatic minification was successful, I can’t bring users to situations where commonWP causes their sites to stop working correctly even though I know I use technique that might cause this, I advertised and promised that commonWP is as secure as possible (and I really believe that this should be the case).
Personally, I strongly believe that this is kind of things that developers of plugins/themes should already enable. I know that maintaining two copies of files was painful but there are now build tools for help. (Core does this: they only have development copies but they have build tool that does minification for release.) Developers should be more responsible with things they put on WP.org repositories, things should be optimized for that environment and general, production usage.
All being said, I’ll add experimental feature for this that is optional and disabled by default, and I will ask for testing it for any issues, but note that it might take a while before I finish it.
Hi there. Thanks for writing such a good plugin! I have read what you said above but I would like to know if it's possible to give the user an option to choose whether to import the original files or the minified files from jsDelivr (SRI will be disabled for sure when importing those minified files ).