Title: jQuery plugin not working with wp_enqueue_script
Last modified: August 30, 2016

---

# jQuery plugin not working with wp_enqueue_script

 *  Resolved [axel98](https://wordpress.org/support/users/axel98/)
 * (@axel98)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/jquery-plugin-not-working-with-wp_enqueue_script/)
 * I’ve tried to put jQuery Fancybox ([http://fancyapps.com/fancybox/](http://fancyapps.com/fancybox/))
   on my WordPress website. As I tried to do this “the way it should be done”, using
   wp_enqueue_script, the script loaded, as I could see in my developer console.
   The plugin didn’t work however. The code I used in functions.php:
 *     ```
       function kls_script_enqueue(){
       	wp_enqueue_script('jQuery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js', array(), null, false);
       	wp_enqueue_style('Fancybox_css', get_template_directory_uri().'/js/fancybox/jquery.fancybox.css');
       	wp_enqueue_script('Fancybox', get_template_directory_uri().'/js/fancybox/jquery.fancybox.js', array('jquery'), null, false);
       }
   
       add_action('wp_enqueue_scripts', 'kls_script_enqueue');
       ```
   
 * In my developer console, I can see that jQuery as well as Fancybox are added.
   The plugin doesn’t work though. Makes you think that I didn’t call the plugin(
   right) or I forgot to add the .fancybox class to my images. But here it comes:
   if I hardcode the script in my header.php, the plugin does work. I can’t seem
   to figure out why this is. When using wp_enqueue_script, jQuery was loaded before
   Fancybox (as it should), so the problem shouldn’t be there.

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

 *  Thread Starter [axel98](https://wordpress.org/support/users/axel98/)
 * (@axel98)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/jquery-plugin-not-working-with-wp_enqueue_script/#post-6837799)
 * I don’t know what happend, but by trying some things, I ended up with a working
   plugin, by registering it first and enqueueing it by just calling the handle.
 *     ```
       wp_register_script( 'fancybox-js', get_template_directory_uri().'/js/fancybox/jquery.fancybox.pack.js', array('jquery'), null, false);
       	wp_enqueue_script('fancybox-js');
       ```
   
 *  Thread Starter [axel98](https://wordpress.org/support/users/axel98/)
 * (@axel98)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/jquery-plugin-not-working-with-wp_enqueue_script/#post-6837800)
 * Another update: now enqueueing the script also directly works. I changed the 
   handle of jQuery from **jQuery** to **jquery** after I read that handles should
   be lower case. That might have been the problem.

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

The topic ‘jQuery plugin not working with wp_enqueue_script’ is closed to new replies.

## Tags

 * [enqueue script](https://wordpress.org/support/topic-tag/enqueue-script/)
 * [jquery plugin](https://wordpress.org/support/topic-tag/jquery-plugin/)

 * 2 replies
 * 1 participant
 * Last reply from: [axel98](https://wordpress.org/support/users/axel98/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/jquery-plugin-not-working-with-wp_enqueue_script/#post-6837800)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
