pcfreak30 / rocket-footer-js

WordPress plugin to force all JS to the footer including inline scripts. Extends WP-Rocket
GNU General Public License v2.0
16 stars 1 forks source link

MailMunch plugin popup not displaying #6

Open ctec25 opened 5 years ago

ctec25 commented 5 years ago

How can I exclude the js for Mailmunch which is popup.js from getting concatenated and moved to the footer?

pcfreak30 commented 5 years ago

Use the attribute data-no-minify="1" on all related script tags

ctec25 commented 5 years ago

Please any ideas on how to add the attribute to the tag of the script. It script is powered by jquery js

pcfreak30 commented 5 years ago

Is it a plugin thats adding the jquery code to load Mailmunch? If so, please link it.

ctec25 commented 5 years ago

Yes it is. https://wordpress.org/plugins/mailmunch/

pcfreak30 commented 5 years ago

Looks like they are echoing out the script tag here https://plugins.svn.wordpress.org/mailmunch/trunk/public/class-mailmunch-public.php

echo('<script data-cfasync="false" src="//a.mailmunch.co/app/v1/site.js" id="mailmunch-script" data-plugin="'.MAILMUNCH_PREFIX.'" data-mailmunch-site-id="'.$siteID.'" async></script>');

I have added a commit to the plugin to support rockets exclude js settings. You need to (for now), overwrite lib/Rocket/Footer/JS.php in the plugins folder with https://raw.githubusercontent.com/pcfreak30/rocket-footer-js/master/lib/Rocket/Footer/JS.php

Then add a.mailmunch.co as an exclusion.

pcfreak30 commented 5 years ago

In the future, I may put in a module to support this, but as it needs testing to see if it can be optimized or just needs to be excluded, will be sometime in the future.

ctec25 commented 5 years ago

Thanks, but It doesn't seem to make any difference after overwrite lib/Rocket/Footer/JS.php and adding a.mailmunch.co to 'Excluded JavaScript Files'

please note that i made sure the wp rocket and cloudflare caches are cleared

pcfreak30 commented 5 years ago

A temp hack then would be to add the attribute to the mailmunch plugin code. The commit I made has not been tested, but I copied much of the logic from rocket itself.

You could also try excluding //a.mailmunch.co/app/v1/site.js.

I could add in a filter into the plugin to be used but then you would need to add PHP to functions to override the behavior.

ctec25 commented 5 years ago

Hi, I have also tried to exclude //a.mailmunch.co/app/v1/site.js and //a.mailmunch.co/app/v1/popover.js which are the scripts that are related to the mailmunch plugins but still get the same result. When I reload the page adding ?nocache the popup displays and those script show up . but without ?nocache at the end of the url, the two scripts are no where to be found meaning they have been combined and the exclusion does not work.

pcfreak30 commented 5 years ago

Have you tried editing the plugin code, based on what I have given, to see if that actually fixes it?

ctec25 commented 5 years ago

Yes, that was the first thing I did before excluding the scripts.

On Mon, 26 Aug 2019, 09:20 Derrick Hammer, notifications@github.com wrote:

Have you tried editing the plugin code, based on what I have given, to see if that actually fixes it?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pcfreak30/rocket-footer-js/issues/6?email_source=notifications&email_token=AIR2OTYZRRSGB4TPF7L4KJLQGOG4XA5CNFSM4IOV2GB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5DVDIQ#issuecomment-524767650, or mute the thread https://github.com/notifications/unsubscribe-auth/AIR2OT6CMEIQB7BVNSSWW3DQGOG4XANCNFSM4IOV2GBQ .

pcfreak30 commented 5 years ago

Stupid question, but with a query string, have you verified the attribute was added? Have you purged the whole cache? The plugin stores transients of files. I would recommend my dedicated transient plugin to better control them.