Title: Javascript in WordPress Plugin
Last modified: August 19, 2016

---

# Javascript in WordPress Plugin

 *  [frent](https://wordpress.org/support/users/frent/)
 * (@frent)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/javascript-in-wordpress-plugin/)
 * Hi, i’m trying to use Javascript in my own WordPress plugin.
    I’ve used this 
   code:
 *     ```
       if (function_exists('wp_register_script')) {
       		$src = "/" . PLUGINDIR . "/XMLProductFeed/js/ReadXML.js";
       		wp_register_script('readxml', $src);
       	}
       ```
   
 * but it shows nothing when I open the plugin page.
    Any ideas? I hope it is not
   something stupid…

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [deanhoover](https://wordpress.org/support/users/deanhoover/)
 * (@deanhoover)
 * [16 years ago](https://wordpress.org/support/topic/javascript-in-wordpress-plugin/#post-1174327)
 * you need to use wp_enqueue_script. I have a follow up question. If I use enqueue
   do I need to use register?
 * Dean
 *  [Russell Heimlich](https://wordpress.org/support/users/kingkool68/)
 * (@kingkool68)
 * [16 years ago](https://wordpress.org/support/topic/javascript-in-wordpress-plugin/#post-1174328)
 * A script needs to be registered first before it can be enqueued. [http://codex.wordpress.org/Function_Reference/wp_enqueue_script](http://codex.wordpress.org/Function_Reference/wp_enqueue_script)
 *  [Matt Cohen](https://wordpress.org/support/users/mattyza/)
 * (@mattyza)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/javascript-in-wordpress-plugin/#post-1174333)
 * Hey frent, deanhoover, kingkool68,
 * Enqueuing Javascript in WordPress seems to be a regular topic of conversation.
   I have had similar issues in the past, including Javascript conflicts caused 
   by incorrectly included Javascript.
 * Please see my blog post on [Javascript and WordPress – The Definitive Guide](http://matty.co.za/2010/03/enqueue-javascript-in-wordpress/)
   for a detailed explanation of how to enqueue Javascript within WordPress plugins
   and themes.
 * I hope this helps. 🙂
 * Cheers,
    Matty.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Javascript in WordPress Plugin’ is closed to new replies.

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * 3 replies
 * 4 participants
 * Last reply from: [Matt Cohen](https://wordpress.org/support/users/mattyza/)
 * Last activity: [15 years, 11 months ago](https://wordpress.org/support/topic/javascript-in-wordpress-plugin/#post-1174333)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
