Loading Javascript in WordPress Plugin

0
(0)

If you’re developing a WordPress plugin and wondering how to load Javascript in your plugin, I’ve found an example below.

There is a hook called wp_enqueue_scripts, which should be used in place 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__ ));
}
Share this:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *