• Resolved SHiRKiT

    (@shirkit)


    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.

    • This topic was modified 8 years, 6 months ago by SHiRKiT.
    • This topic was modified 8 years, 6 months ago by SHiRKiT.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter SHiRKiT

    (@shirkit)

    Also, as an additional quesiton, can I disable the Google Fonts usage?

    I’m bundling all my fonts in a single file with base64 encoding, which is proving to be faster due to 3G connections having huge RRT times here. I could just put Roboto there as well.

    Plugin Author GusRuss89

    (@gusruss89)

    Hi @shirkit

    I’m not sure why you’re getting that behaviour, but it sounds more to do with CF7 than my plugin.

    Here’s a support thread from a few weeks ago also about performance. I recommended using Autoptimize for deferring and concatenating scripts, and there’s also some PHP to dequeue stylesheets etc on pages where you don’t need it.

    https://ww.wp.xz.cn/support/topic/above-the-fold-blocking/

    Thanks,
    Angus

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

The topic ‘Async load causes plugin malfunction’ is closed to new replies.