Title: Google Closure Breaks Javascript
Last modified: July 29, 2021

---

# Google Closure Breaks Javascript

 *  Resolved [launchinteractive](https://wordpress.org/support/users/launchinteractive/)
 * (@launchinteractive)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/google-closure-breaks-javascript/)
 * When you use Google Closure to compress wootpm.js it has trouble with the varExists
   function.
 *     ```
       if (typeof varExists !== "function") {
           function varExists(varName) {
       ```
   
 * becomes:
 * `if("function"!==typeof varExists)var varExists$0=function(a){`
 * which is incorrect. To correct this I believe this is all that needs to change:
 *     ```
       if (typeof varExists !== "function") {
           window.varExists = function(varName) {
       ```
   

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

 *  Plugin Author [alekv](https://wordpress.org/support/users/alekv/)
 * (@alekv)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/google-closure-breaks-javascript/#post-14719875)
 * I’ll look into it. It looks logical and simple. But I remember having had issues
   with a function trying to declare it under window. For some reason it broke, 
   even if it shouldn’t. So I’ll have to carefully test it.
 * I’ll let you know what I find out in the next few days.
    -  This reply was modified 4 years, 10 months ago by [alekv](https://wordpress.org/support/users/alekv/).
    -  This reply was modified 4 years, 10 months ago by [alekv](https://wordpress.org/support/users/alekv/).
 *  Thread Starter [launchinteractive](https://wordpress.org/support/users/launchinteractive/)
 * (@launchinteractive)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/google-closure-breaks-javascript/#post-14721179)
 * Thanks. It should also work without window but I added it to make it clearer 
   that it is a global function.
 *  Plugin Author [alekv](https://wordpress.org/support/users/alekv/)
 * (@alekv)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/google-closure-breaks-javascript/#post-14736438)
 * I released a new version with that code adjusted.
 * Let me know if it works.
 *  Thread Starter [launchinteractive](https://wordpress.org/support/users/launchinteractive/)
 * (@launchinteractive)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/google-closure-breaks-javascript/#post-14736581)
 * That’s done it. Works great. Thanks.

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

The topic ‘Google Closure Breaks Javascript’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-google-adwords-conversion-tracking-tag/assets/
   icon-256x256.png?rev=2704744)
 * [Pixel Manager for WooCommerce – Conversion Tracking, Google Ads, GA4, TikTok, Dynamic Remarketing](https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-tag/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-tag/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [launchinteractive](https://wordpress.org/support/users/launchinteractive/)
 * Last activity: [4 years, 10 months ago](https://wordpress.org/support/topic/google-closure-breaks-javascript/#post-14736581)
 * Status: resolved