• Resolved apremierdj

    (@apremierdj)


    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 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

    (@optimizingmatters)

    chimpPopupLoader should to the trick 🙂

    Thread Starter apremierdj

    (@apremierdj)

    That did not work unfortunately. I placed the name in the “Exclude scripts from Autoptimize:” section

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    it does get excluded when I go to 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

    (@apremierdj)

    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

    (@optimizingmatters)

    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

    (@apremierdj)

    Where exactly can defer=’defer’ be removed? I’m a bit confused on this part.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    that I don’t know @apremierdj; AO does not add that, so probably you have some other plugin adding the defer flag?

    Thread Starter apremierdj

    (@apremierdj)

    I disable all plugins except Autoptimize and receive the same result. Any other ideas please 🙂

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    errr … dunno … your theme maybe? or something like cloudflare?

    Thread Starter apremierdj

    (@apremierdj)

    Yes I have cloud flare…what should i look into?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    don’t know cloudflare that well, but look for settings about deferring code (js) maybe?

    Thread Starter apremierdj

    (@apremierdj)

    I disabled cloud flare and no luck either.

    Thread Starter apremierdj

    (@apremierdj)

    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

    (@optimizingmatters)

    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

    (@optimizingmatters)

    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.