Title: Plugin does ignore jQuery dependency
Last modified: March 19, 2017

---

# Plugin does ignore jQuery dependency

 *  [mxmtsk](https://wordpress.org/support/users/mxmtsk/)
 * (@mxmtsk)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/plugin-does-ignore-jquery-dependency/)
 * In selection-sharer.php the script get’s added with
 * `wp_enqueue_script( 'selection-sharer-js', plugins_url('/js/selection-sharer.
   js', __FILE__), false, '0.1');`
 * But it has jQuery as a dependency so it should be
 * `wp_enqueue_script( 'selection-sharer-js', plugins_url('/js/selection-sharer.
   js', __FILE__), array('jquery'), '0.1');`
 * Also, the init script does get added right after and ignores the jQuery dependency.
   In my case this lead to the line being added before jQuery was loaded. An undefined
   error was thrown. I managed to modify the plugin to make it work in my case but
   this should really be fixed.

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

 *  Plugin Author [jcvangent](https://wordpress.org/support/users/jcvangent/)
 * (@jcvangent)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/plugin-does-ignore-jquery-dependency/#post-8933653)
 * Hey [@mxmtsk](https://wordpress.org/support/users/mxmtsk/),
 * thanks for the remarks, will make a small update around this and update it with
   the code you supplied here.
 * Does that undefined error still happen when you change this line?
 *  Thread Starter [mxmtsk](https://wordpress.org/support/users/mxmtsk/)
 * (@mxmtsk)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/plugin-does-ignore-jquery-dependency/#post-8933932)
 * Hi [@jcvangent](https://wordpress.org/support/users/jcvangent/),
 * for the script it resolves the error yes, but the line below where you simple
   echo the initialization does not work. You would need to add the line
 * `jQuery(document).ready(function ($) { $('p').selectionSharer();});`
 * to the plugins JS file (seems a bit dirty for me but I could live with it) or
   in a new file (another request, not very efficient) or find a way to print inline
   script that is aware of the dependency. I’m not sure that there is a method for
   this in WordPress.
 * I removed the line and put it in my own custom js file but that is of course 
   not applicable for normal users. I would go with the first solution.

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

The topic ‘Plugin does ignore jQuery dependency’ is closed to new replies.

 * ![](https://ps.w.org/selection-sharer/assets/icon-256x256.png?rev=1079512)
 * [Selection Sharer by Hans van Gent](https://wordpress.org/plugins/selection-sharer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/selection-sharer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/selection-sharer/)
 * [Active Topics](https://wordpress.org/support/plugin/selection-sharer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/selection-sharer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/selection-sharer/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [mxmtsk](https://wordpress.org/support/users/mxmtsk/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/plugin-does-ignore-jquery-dependency/#post-8933932)
 * Status: not resolved