I made a few animations locally with anime.js with plain HTML, CSS and JS. Now I need to implement these animations in a wordpress-based site.
Unfortunately I get the error module is not defined
. It refers to the last line in the anime.js file module.exports = anime;
.
I really don't know much about Wordpress development but I do know how to enqueue scripts (at least I think I do)
Here's the code from my functions.php file where I call anime.js and my js file although I don't even know if this error has something to do with how I enqueue the files.
function load_my_scripts() {
wp_register_script('animejs', get_template_directory_uri() . "/js/anime.js", array(), '', true );
wp_enqueue_script('animejs');
wp_register_script('scriptjs', get_template_directory_uri() . "/js/script.js", array('animejs'), '', true );
wp_enqueue_script('scriptjs');
}
add_action('init', 'load_my_scripts');
The site on which the problem occurs is this one: http://www.provokatur.at/
I really hope that someone can help me out, thanks.
I figured it out.
I don't enqueue the anime.js file anymore, I just register it with:
wp_register_script('animejs', 'https://cdnjs.cloudflare.com/ajax/libs/animejs/2.2.0/anime.min.js');
After that the animation just did not get executed, all I did to fix this was to add
jQuery(document).ready(function($){
//Code goes here
})
Apparently this executes the animation with jQuery... Although I really don't understand the reasoning behind this I still hope that my explanation helps some people.