enqueue a javascript file
-
Hi,
Can you give me please the PHP code to put in functions.php of a child theme to enqueue a javascript file located in the child theme folder.
I don’t want to use Custom JS feature from theme options because i want the code to be loaded into an external file, not inline.
Thanks
-
This topic was modified 2 years, 3 months ago by
Jean Bon.
Hello Jean Bon,
Thanks for reaching to us.
You need to first dequeue the parent theme JS file and then enqueue your own from the child theme. But I suggest you not to override this way but simply add another JS file where you can write your code or use our Custom JS in Theme Settings.
If you still want to do this, you will need to add a localization array as well. You can find how to do this in the file funcitons.php PHP function – woodmart_enqueue_scripts
Regards,