I have a WordPress site that uses several plugins, namely 8. Most of these plugins include a lot of their own JS and CSS files, some even include so much as 3 separate CSS files. One can imagine that this does a number on the amount of HTTP requests and thus the load time.
Many of these plugins also only get used on certain pages, yet the JS or CSS is still loaded on pages where they are not used.
All of theses files are included automatically in the through WP_head();. Is there a way I can manually include these files and then load them conditionally? Preferably without having to adjust the plugin code itself?
Are there other common practices regarding the many files included by a bigger number of plugins?
Previous versions of WordPress didn’t really provide a good means to conditionally enqueue stylesheets and JavaScript within a plugin (i.e. only when needed). So most plugin authors enqueued both on every WordPress init/load, even if the plugin wasn’t being used on a given page.
Current versions of WordPress allow for enqueuing later in the flow so you you can, for example, enqueue on your shortcode init/parse.
So you really have only a few options here:
Hopefully other users here might have some suggestions for you.
You can try this plugin: http://wordpress.org/extend/plugins/wp-minify/ it allows you to consolidate and minify your JS and CSS
Besides WP Minify, I would recommend you to use the Selective Loading Plugin.
It’ll help you load only the plugins you want to load based on pages/posts and categories and it will improve your WP’s loading time.