I am very new to build Wordpress Website, so please bear with me if I don't describe things properly.
There is a website providing the .js file for flying bats on the screen. /
It says that I can just insert the script by using
<script async src=".js"></script>
but it doesn't work on the website.
What did I do wrong? Do I have to change something in the JS file?
Thank you in advance.
I am very new to build Wordpress Website, so please bear with me if I don't describe things properly.
There is a website providing the .js file for flying bats on the screen. https://www.delphitools.info/2013/10/30/pimp-your-website-with-an-halloween-bat/
It says that I can just insert the script by using
<script async src="https://cdn.delphitools.info/wp-content/uploads/2013/10/jsbat.js"></script>
but it doesn't work on the website.
What did I do wrong? Do I have to change something in the JS file?
Thank you in advance.
I believe you've downloaded that jsbat.js file somewhere in your wordpress root directory consider this your root directory of web
/xampp/htdocs/wordpress_site/wp-content/themes/theme-name/assets/js/jsbat.js
now you'll need to find functions.php file in your theme. Typically this resides in this folder:
/xampp/htdocs/wordpress_site/wp-content/themes/theme-name/functions.php
edit functions.php file, and add following code:
add_action( 'wp_enqueue_scripts', 'fy_load_scripts' );
function fy_load_scripts(){
wp_enqueue_script( 'jsbat-script-js', get_template_directory_uri(). '/assets/js/jsbat.js', array( 'jquery' ), '1.0.0', true );
}
this is just generalized answer, please modify ( you won't need to create function 'fy_load_scripts' but in case you don't know what to do just copy and paste the code in functions.php file and the directory structure should be matched as well )
Hope this helps Good luck!