WP-Optimize Minify may break plugin ES module scripts using import statements
-
Hi, I found a compatibility issue between WP-Optimize Minify and a WordPress plugin that uses frontend ES module scripts.
The plugin enqueues a JavaScript file that contains ES module imports, so it must be loaded with type=”module”. When WP-Optimize JavaScript minification/combination is enabled, the frontend animation script either does not load correctly or is processed in a way that causes the browser error:
Uncaught SyntaxError: Cannot use import statement outside a module
After excluding the plugin’s JS module files from WP-Optimize minification, the issue disappears and the animation works correctly.
Could you please check how WP-Optimize handles scripts registered with type=”module” or scripts modified through the script_loader_tag filter?
Affected files in my case:
Affected files in Timeline Full Widget 2.2.0:
- https://plugins.svn.ww.wp.xz.cn/timeline-full-widget/tags/2.2.0/assets/js/adapters/gutenberg-adapter.js
- https://plugins.svn.ww.wp.xz.cn/timeline-full-widget/tags/2.2.0/assets/js/core/animation.js
Expected behavior:
WP-Optimize should preserve type=”module” and avoid combining ES module scripts with regular scripts, or provide a reliable exclusion mechanism for module scripts. Thanks.
You must be logged in to reply to this topic.