If you’re developing a WordPress plugin and wondering how to load Javascript in your plugin, below is an example I’ve found it here. There is a hook called wp_enqueue_scripts
, which should be used in lieu of init
for loading scripts.
<?php add_action('wp_enqueue_scripts','ava_test_init'); function ava_test_init() { wp_enqueue_script( 'ava-test-js', plugins_url( '/js/ava_test_.js', __FILE__ )); }