Title: Loading JS in plugin
Last modified: September 1, 2016

---

# Loading JS in plugin

 *  [ctuxboy](https://wordpress.org/support/users/ctuxboy/)
 * (@ctuxboy)
 * [10 years ago](https://wordpress.org/support/topic/loading-js-in-plugin/)
 * Hello,
 * I try adding a JS file for a plugin settings page.
    The setting page works, and
   when i adding the JS code directly in the settings-page function, then the JS
   works. But when adding the JS-code in a file, it doesn’t work: plugin-name**/
   js/hk-color.js**
 * Now trying with this function, loading the JS file:
 *     ```
       ...
       function hk_scripts() { // adding my scripts
       	wp_enqueue_script( 'hk-color', plugins_url( '/js/hk-color.js', __FILE__ ));
       }
       add_action( 'wp_enqueue_scripts', 'hk_scripts' );
       ...
       ```
   
 * But the script **hk-color.js** doesn’t load.
 * How can loading een js-script needed for my plugin?
 * PS: I try implement this color picker, and follow the tutorial: [http://www.wordpresscheatsheets.com/how-to-add-wordpress-color-picker](http://www.wordpresscheatsheets.com/how-to-add-wordpress-color-picker)
 * Christophe

The topic ‘Loading JS in plugin’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [ctuxboy](https://wordpress.org/support/users/ctuxboy/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/loading-js-in-plugin/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
