best place to put javascript in wordpress function.php or function.js -


what best place put javascript function in wordpress? more appropriate in function.js or in function.php file? there difference in term of performance?

i typically put custom functions in own js files easy organization enqueue in function.php file.

https://codex.wordpress.org/function_reference/wp_enqueue_script

this works if script has dependency such jquery.

wp_register_script('script-name', get_template_directory_uri() . '/js/myawesomescript.min.js', array('jquery'), '1.0.0'); wp_enqueue_script('script-name'); // enqueue it! 

hope helps.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -