Title: script in footer.php
Last modified: November 22, 2018

---

# script in footer.php

 *  [catchbudapest](https://wordpress.org/support/users/catchbudapest/)
 * (@catchbudapest)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/script-in-folder/)
 * Hi,
 * I am using Mailchimp and want to get the Mailchimp subscribe popup working on
   onclick
    (the standard popups can only be triggered immediately, after 5 seconds,
   after 20 seconds, after the visitors scrolls to the middle of the page, but not
   on a click.)
 * To get this working a litte workaround is necessary, which is described [here](https://preeny.com/blog/get-mailchimp-subscribe-popup-working-onclick-wordpress/).
 * It is necessary to add this script to the footer.php:
 *     ```
       <script type="text/javascript" src="//downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script>
       <script>
       function showMailingPopUp() {
         require(
           ["mojo/signup-forms/Loader"],
           function(L) {
             L.start({"baseUrl":"mc.us16.list-manage.com","uuid":"YOUR_UUID","lid":"YOUR_LID"})
           }
         );
   
         document.cookie = 'MCPopupClosed=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;';
         document.cookie = 'MCPopupSubscribed=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;';
       }
   
       document.getElementById("open-popup").onclick = function() {showMailingPopUp()};
       </script>
       ```
   
 * The workaround works for me as long as Autoptimize is deactivated.
 * Is there a way (e.g. a specific setting) to get this workaround working together
   with Autoptimize?
 * Currently Autoptimize is deactivated and [here ](https://www.catchbudapest.com/free-hungarian-course/)
   is the current page I am working on.
    -  This topic was modified 7 years, 6 months ago by [catchbudapest](https://wordpress.org/support/users/catchbudapest/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fscript-in-folder%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/script-in-folder/#post-10906596)
 * well you can re-enable AO and probalby fix this with one of the following options;
   
   1. keep JS optimization off 2. enable JS optimization but make sure “aggregate
   inline scripts” is off 3. enable JS optimization and add `showMailingPopUp` to
   the comma-separated list of JS optimization exclusions
 * hope this helps,
    frank
 *  Thread Starter [catchbudapest](https://wordpress.org/support/users/catchbudapest/)
 * (@catchbudapest)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/script-in-folder/#post-10906782)
 * Hi Frank,
 * thanks for the quick reply!
 * Only the following options fix the problem:
    1. disable JS optimization, or 2.
   disable Aggregate JS-files
 * As soon “Aggregate JS-files” is enabled, the script is not working anymore, even
   though “aggregate inline JS” is disabled and “showMailingPopUp” is added to the
   exclusion.
 * Any other suggestions in order too keep the option “Aggregate JS-files” on?
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/script-in-folder/#post-10906821)
 * well, let’s dig in with some questions, shall we? 😉
 * * can you confirm that when excluding `showMailingPopUp` that JS is in the HTML
   source?
    * does mailchimp require extra JS being loaded which you might have 
   to exlude? * is there a JS error on the browser console that could teach us what
   is wrong?
 *  Thread Starter [catchbudapest](https://wordpress.org/support/users/catchbudapest/)
 * (@catchbudapest)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/script-in-folder/#post-10906923)
 * OK, lets’s try 🙂
 * > * can you confirm that when excluding showMailingPopUp that JS is in the HTML
   > source?
 * Yes, still in the source code.
 * > * does mailchimp require extra JS being loaded which you might have to exlude?
   > *
   > is there a JS error on the browser console that could teach us what is wrong?
 * The browser console shows an error about embed.js, seems that is part of mailchimp:
   //
   downloads.mailchimp.com/js/signup-forms/popup/embed.js
 * I added embed.js to the to the exclusion, but didn’t work.
    -  This reply was modified 7 years, 6 months ago by [catchbudapest](https://wordpress.org/support/users/catchbudapest/).
 *  Thread Starter [catchbudapest](https://wordpress.org/support/users/catchbudapest/)
 * (@catchbudapest)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/script-in-folder/#post-10906935)
 * btw the console shows also an error about autoptimize (see [screenshot](http://prntscr.com/llky4z)).
 * Is that normal?
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/script-in-folder/#post-10906938)
 * OK, can you copy/paste the exact error-message?
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/script-in-folder/#post-10906971)
 * I would need the full error-messages [@catchbudapest](https://wordpress.org/support/users/catchbudapest/).
   not sure what browser you’re using, but guess you can visualize them by clicking
   on the error-indicator in your screenshot?
 *  Thread Starter [catchbudapest](https://wordpress.org/support/users/catchbudapest/)
 * (@catchbudapest)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/script-in-folder/#post-10906998)
 * damn, I feel a bit stupid but the chrome console doesn’t show more information
   about the errors then showed in the screenshot (no idea where to see the details…)
 * so I switched to firefox console, I get the following messages there:
 * **conserning embed.js**
 * > Synchrone XMLHttpRequests am Haupt-Thread sollte nicht mehr verwendet werden,
   > weil es nachteilige Effekte für das Erlebnis der Endbenutzer hat. Für weitere
   > Hilfe siehe [http://xhr.spec.whatwg.org/](http://xhr.spec.whatwg.org/) embed.
   > js:6:4
 * **and autoptimize….js:**
 * > TypeError: links.not(…).addClass(…).magnificPopup is not a function autoptimize_9cdaeb734b0cd2de928d3a18bef95aba.
   > js:1177:145
   >  $.fn.avia_activate_lightbox/</< [https://www.catchbudapest.com/wp-content/cache/autoptimize/js/autoptimize_9cdaeb734b0cd2de928d3a18bef95aba.js:1177:145](https://www.catchbudapest.com/wp-content/cache/autoptimize/js/autoptimize_9cdaeb734b0cd2de928d3a18bef95aba.js:1177:145)
   > each [https://www.catchbudapest.com/wp-includes/js/jquery/jquery.js:2:2879](https://www.catchbudapest.com/wp-includes/js/jquery/jquery.js:2:2879)
   > each [https://www.catchbudapest.com/wp-includes/js/jquery/jquery.js:2:844](https://www.catchbudapest.com/wp-includes/js/jquery/jquery.js:2:844)
   > $.fn.avia_activate_lightbox/< [https://www.catchbudapest.com/wp-content/cache/autoptimize/js/autoptimize_9cdaeb734b0cd2de928d3a18bef95aba.js:1176:36](https://www.catchbudapest.com/wp-content/cache/autoptimize/js/autoptimize_9cdaeb734b0cd2de928d3a18bef95aba.js:1176:36)
   > each [https://www.catchbudapest.com/wp-includes/js/jquery/jquery.js:2:2879](https://www.catchbudapest.com/wp-includes/js/jquery/jquery.js:2:2879)
   > each [https://www.catchbudapest.com/wp-includes/js/jquery/jquery.js:2:844](https://www.catchbudapest.com/wp-includes/js/jquery/jquery.js:2:844)
   > $.fn.avia_activate_lightbox [https://www.catchbudapest.com/wp-content/cache/autoptimize/js/autoptimize_9cdaeb734b0cd2de928d3a18bef95aba.js:1174:920](https://www.catchbudapest.com/wp-content/cache/autoptimize/js/autoptimize_9cdaeb734b0cd2de928d3a18bef95aba.js:1174:920)
   > $.avia_utilities.avia_ajax_call [https://www.catchbudapest.com/wp-content/cache/autoptimize/js/autoptimize_9cdaeb734b0cd2de928d3a18bef95aba.js:97:204](https://www.catchbudapest.com/wp-content/cache/autoptimize/js/autoptimize_9cdaeb734b0cd2de928d3a18bef95aba.js:97:204)
   > <anonym> [https://www.catchbudapest.com/wp-content/cache/autoptimize/js/autoptimize_9cdaeb734b0cd2de928d3a18bef95aba.js:96:43](https://www.catchbudapest.com/wp-content/cache/autoptimize/js/autoptimize_9cdaeb734b0cd2de928d3a18bef95aba.js:96:43)
   > i [https://www.catchbudapest.com/wp-includes/js/jquery/jquery.js:2:27444](https://www.catchbudapest.com/wp-includes/js/jquery/jquery.js:2:27444)
   > fireWith [https://www.catchbudapest.com/wp-includes/js/jquery/jquery.js:2:28213](https://www.catchbudapest.com/wp-includes/js/jquery/jquery.js:2:28213)
   > ready [https://www.catchbudapest.com/wp-includes/js/jquery/jquery.js:2:30004](https://www.catchbudapest.com/wp-includes/js/jquery/jquery.js:2:30004)
   > K [https://www.catchbudapest.com/wp-includes/js/jquery/jquery.js:2:30366](https://www.catchbudapest.com/wp-includes/js/jquery/jquery.js:2:30366)
 * hope that is what you were asking/looking for
 *  Thread Starter [catchbudapest](https://wordpress.org/support/users/catchbudapest/)
 * (@catchbudapest)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/script-in-folder/#post-10907105)
 * not sure if my last message went through.
 * got the following message:
    This post has been held for moderation by our automated
   system and will be manually reviewed by a moderator.
 * I suppose you are the moderator, but just wanted to be sure :))
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/script-in-folder/#post-10907224)
 * it did not go through but i am not (a moderator). we’ll have to be patient I 
   guess 😉
 *  Thread Starter [catchbudapest](https://wordpress.org/support/users/catchbudapest/)
 * (@catchbudapest)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/script-in-folder/#post-10907347)
 * Abort mission 🙂
 * In order to save us both some time I give up on the popup, and just use a standard
   form.
 * Thanks anyway for the great und quick support!!
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/script-in-folder/#post-10907396)
 * you’re welcome catchbudapest, feel free to [leave a review of the plugin and support here](https://wordpress.org/support/plugin/autoptimize/reviews/#new-post)!
   🙂

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

The topic ‘script in footer.php’ is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 12 replies
 * 2 participants
 * Last reply from: [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * Last activity: [7 years, 6 months ago](https://wordpress.org/support/topic/script-in-folder/#post-10907396)
 * Status: not resolved