I’m facing issues with enqueuing JavaScript files in the Gutenberg editor. While it works on the front end, when these files are loaded, particularly main.js which initializes WOW.js, it causes the blocks to render as blank. This is likely due to a conflict with the editor’s JavaScript. ( I assumed its a conflict with wordpress js)
Here’s the current code I’ve used for enqueuing CSS and JavaScript in filters.php:
add_action('after_setup_theme', function () {
add_theme_support('editor-styles');
add_editor_style('/public/styles/fontawesome/css/all.min.css');
add_editor_style('/public/styles/bootstrap-icons/font/bootstrap-icons.min.css');
add_editor_style('/public/lib/animate/animate.min.css');
add_editor_style('/public/styles/bootstrap.min.css');
add_editor_style('/public/styles/app.css');
});
add_action('enqueue_block_editor_assets', function () {
wp_enqueue_script('jquery');
wp_enqueue_script('sage-editor-bootstrap', 'https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.bundle.min.js', ['jquery'], false, true);
wp_enqueue_script('sage-editor-wow', get_template_directory_uri() . '/public/lib/wow/wow.min.js', ['jquery'], false, true);
wp_enqueue_script('sage-editor-easing', get_template_directory_uri() . '/public/lib/easing/easing.min.js', ['jquery'], false, true);
wp_enqueue_script('sage-editor-waypoints', get_template_directory_uri() . '/public/lib/waypoints/waypoints.min.js', ['jquery'], false, true);
wp_enqueue_script('sage-editor-counterup', get_template_directory_uri() . '/public/lib/counterup/counterup.min.js', ['jquery'], false, true);
wp_enqueue_script('sage-editor-main', get_template_directory_uri() . '/public/js/main.js', ['jquery'], false, true);
});
when the main.js is enqueued it create that problem since it initiates the wowjs
new WOW().init();
Does anyone know how to solve this problem, or should I use another alternative for WOW.js?