Async load causes plugin malfunction
-
Hey,
So I’ve been trying to improve my loading times in my local dev website, so I tried to load the scripts that MDfCF7 needs using an eval after the page is already loaded.
But when I do that, when I click the submit button, the page is loaded with localhost/wordpress/#wpcf7-f4-p82-o1 and the design breaks, instead of the default behavior, that is to block the page reload and present the errors/sucess below the form.
Here’s how I’m loading the code, I don’t get what I’m doing wrong, since doing defer in the script works perfectly.
const scripts = {contact:["https://shirkit.local/wordpress/wp-content/plugins/contact-form-7/includes/js/scripts.js","https://shirkit.local/wordpress/wp-content/plugins/material-design-for-contact-form-7/public/../assets/js/lib/material-components-web.min.js","https://shirkit.local/wordpress/wp-content/plugins/material-design-for-contact-form-7/public/../assets/js/lib/autosize.min.js","https://shirkit.local/wordpress/wp-content/plugins/material-design-for-contact-form-7/public/../assets/js/cf7-material-design.js"]}; jQuery.getMultiScriptsSeq = function(scripts) { var xhrs = scripts.map(function(url) { return $.ajax({ url: url, dataType: 'text', cache: true }); }); return $.when.apply($, xhrs).done(function() { Array.prototype.forEach.call(arguments, function(res) { window.eval.call(this, res[0]); }); }); } jQuery.getMultiScriptsSeq(scripts.contact);shirkit.local is just a shortcut to localhost.
The topic ‘Async load causes plugin malfunction’ is closed to new replies.