syner
syner

Reputation: 96

Is it good to defer wordpress plugin css/script

While going through different website speed test, it seems that my site is making too many server requests mainly for css/js used by plugins, cache plugins seems to be combining css/js, But I want to know is it good practice to defer css/js manually and add them to one css/js like main.css / main.js

Defering css/js:

add_action('wp_enqueue_scripts', 'mytheme_dequeue_css_from_plugins', 100);
function mytheme_dequeue_css_from_plugins()  {

    wp_dequeue_style('wpmtst-font-awesome'); 
    wp_deregister_style("contact-form-7");

}

Upvotes: 0

Views: 245

Answers (1)

Graeme
Graeme

Reputation: 46

Specifically on mobile devices one of the largest performance overheads is the creation of HTTP requests themselves - so it’s always good practice to limit where you can.

Additionally (for all browsers) the concurrent request limits play a significant part. See this post for more details. Noting that subdomains increase this limit... eg. //images.mydomain.com

“Perceived performance” (time to first render, FOUC) on unprimed views are also impacted where multiple requests for files, such as CSS, “block” the concurrent loading of visual assets (images, logos, fonts etc.) from the same origin.

So yes, if you can bundle these using the code you posted, it’s worth doing.

Hope this helps.

Upvotes: 0

Related Questions