Title: Mail Chimp Popup Code
Last modified: August 2, 2017

---

# Mail Chimp Popup Code

 *  Resolved [apremierdj](https://wordpress.org/support/users/apremierdj/)
 * (@apremierdj)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/)
 * I’ve add a mail chimp pop up code to my site but your plugin setting “Also aggregate
   inline JS?” breaks the code. I believe i need to exclude the code from optimizing.
   Can someone help? My website is [http://www.stlouisdj.com](http://www.stlouisdj.com)
   and here is the code:
 * <script>
    // Fill in your MailChimp popup settings below. // These can be found
   in the original popup script from MailChimp. var mailchimpConfig = { baseUrl:‘
   mc.us9.list-manage.com’, uuid: ‘768905a4851178f5dcdb5419d’, lid: ‘209362e952’};
 *  // No edits below this line are required
    var chimpPopupLoader = document.createElement(“
   script”); chimpPopupLoader.src = ‘//s3.amazonaws.com/downloads.mailchimp.com/
   js/signup-forms/popup/embed.js’; chimpPopupLoader.setAttribute(‘data-dojo-config’,‘
   usePlainJson: true, isDebug: false’);
 *  var chimpPopup = document.createElement(“script”);
    chimpPopup.appendChild(document.
   createTextNode(‘require([“mojo/signup-forms/Loader”], function (L) { L.start({“
   baseUrl”: “‘ + mailchimpConfig.baseUrl + ‘”, “uuid”: “‘ + mailchimpConfig.uuid
   + ‘”, “lid”: “‘ + mailchimpConfig.lid + ‘”})});’));
 *  jQuery(function ($) {
    document.body.appendChild(chimpPopupLoader);
 *  $(window).load(function () {
    document.body.appendChild(chimpPopup); });
 *  });
    </script>

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

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/#post-9372209)
 * `chimpPopupLoader` should to the trick 🙂
 *  Thread Starter [apremierdj](https://wordpress.org/support/users/apremierdj/)
 * (@apremierdj)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/#post-9372245)
 * That did not work unfortunately. I placed the name in the “Exclude scripts from
   Autoptimize:” section
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/#post-9372255)
 * it does get excluded when I go to [https://www.stlouisdj.com/?Qdsfqsd=qdsq](https://www.stlouisdj.com/?Qdsfqsd=qdsq),
   so you’ll have to clear your page cache (plugin or hoster or 3rd party service?)
 *  Thread Starter [apremierdj](https://wordpress.org/support/users/apremierdj/)
 * (@apremierdj)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/#post-9372270)
 * Still no luck.
 * This is a popup created by MailChimp. You should see a popup 5 seconds after 
   home page load.
 * The only way I found to fix was to uncheck the “Also aggregate inline JS?” but
   this greatly reduces my google score.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/#post-9372432)
 * ahh, but that I didn’t check, only thing I can confirm is that the relevant JS
   was excluded 🙂
 * so have a look at your browser console and you’ll see a “jquery is not defined”-
   error, which is due to the `defer='defer'` added to the excluded jquery.js script
   tag (I guess by a plugin). remove that and it will probably work.
 *  Thread Starter [apremierdj](https://wordpress.org/support/users/apremierdj/)
 * (@apremierdj)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/#post-9373895)
 * Where exactly can defer=’defer’ be removed? I’m a bit confused on this part.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/#post-9373949)
 * that I don’t know [@apremierdj](https://wordpress.org/support/users/apremierdj/);
   AO does not add that, so probably you have some other plugin adding the defer
   flag?
 *  Thread Starter [apremierdj](https://wordpress.org/support/users/apremierdj/)
 * (@apremierdj)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/#post-9374181)
 * I disable all plugins except Autoptimize and receive the same result. Any other
   ideas please 🙂
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/#post-9374396)
 * errr … dunno … your theme maybe? or something like cloudflare?
 *  Thread Starter [apremierdj](https://wordpress.org/support/users/apremierdj/)
 * (@apremierdj)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/#post-9374400)
 * Yes I have cloud flare…what should i look into?
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/#post-9374416)
 * don’t know cloudflare that well, but look for settings about deferring code (
   js) maybe?
 *  Thread Starter [apremierdj](https://wordpress.org/support/users/apremierdj/)
 * (@apremierdj)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/#post-9374575)
 * I disabled cloud flare and no luck either.
 *  Thread Starter [apremierdj](https://wordpress.org/support/users/apremierdj/)
 * (@apremierdj)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/#post-9374581)
 * It really don’t make sense why I can disable “Also aggregate inline JS?” and 
   it works but if I enable “Also aggregate inline JS?” but exclude the script, 
   it doesn’t work.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/#post-9374818)
 * > I disabled cloud flare and no luck either.
 * well, do you have anything in your functions.php which says “defer”? or elsewhere?
   there _has_ to be _something_
 * > It really don’t make sense why I can disable “Also aggregate inline JS?” and
   > it works but if I enable “Also aggregate inline JS?” but exclude the script,
   > it doesn’t work.
 * it does though, from a technical point of view; your inline JS depends jquery.
   if both jquery & the inline JS are autoptimized (i.e. not excluded), both are
   executed in the right order. if you exclude the inline JS, it needs but can not
   find jQuery either because jquery is autoptimized (in which case it is loaded
   late) or because jQuery is deferred (for reasons I do not know), so the inline
   JS is broken.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/#post-9495250)
 * marking as resolved as AO-related question was answered, remaining issue is due
   to something out of AO’s reach (which I’d still like to know what was causing
   that).

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

The topic ‘Mail Chimp Popup Code’ 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/)

 * 15 replies
 * 2 participants
 * Last reply from: [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * Last activity: [8 years, 9 months ago](https://wordpress.org/support/topic/mail-chimp-popup-code/#post-9495250)
 * Status: resolved