Title: jQuery declaration issue
Last modified: March 22, 2022

---

# jQuery declaration issue

 *  Resolved [btaens](https://wordpress.org/support/users/btaens/)
 * (@btaens)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/jquery-declaration-issue/)
 * We were having an issue with the plugin’s javascript components not working, 
   for example, when certain fields needed to be hidden or shown based on another
   fields value.
 * We figured out the issue was with how the plugin declares the “$” variable. It
   does not seem to check whether it has been declared before, and in our case another
   component has already declared it with const, and the entire javascript portion
   of WC Fields Factory crashed at the first line as a result.
 * Instead of simply declaring:
    `var $ = jQuery;` A safety check should be done
   beforehand:
 *     ```
       if (typeof $ == 'undefined') {
           const $ = jQuery;
       }
       ```
   
 * Please, implement the fix so we can keep upgrading the plugin.
    -  This topic was modified 4 years, 1 month ago by [btaens](https://wordpress.org/support/users/btaens/).
      Reason: Added code blocks
    -  This topic was modified 4 years, 1 month ago by [btaens](https://wordpress.org/support/users/btaens/).
      Reason: changed solution for "strict" mode
    -  This topic was modified 4 years, 1 month ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).

Viewing 1 replies (of 1 total)

 *  Plugin Author [Saravana Kumar K](https://wordpress.org/support/users/mycholan/)
 * (@mycholan)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/jquery-declaration-issue/#post-15485900)
 * Thanks you for the report.
    I will make sure upcoming releases include this fix
   as well.

Viewing 1 replies (of 1 total)

The topic ‘jQuery declaration issue’ is closed to new replies.

 * ![](https://ps.w.org/wc-fields-factory/assets/icon-128x128.jpg?rev=2738843)
 * [WC Fields Factory](https://wordpress.org/plugins/wc-fields-factory/)
 * [Support Threads](https://wordpress.org/support/plugin/wc-fields-factory/)
 * [Active Topics](https://wordpress.org/support/plugin/wc-fields-factory/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wc-fields-factory/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wc-fields-factory/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Saravana Kumar K](https://wordpress.org/support/users/mycholan/)
 * Last activity: [4 years, 1 month ago](https://wordpress.org/support/topic/jquery-declaration-issue/#post-15485900)
 * Status: resolved